Sha256: 18f06ecc63d46f6b6222e2d5d4b19532809fcc576187bdf2f077925876e9570c
Contents?: true
Size: 907 Bytes
Versions: 38
Compression:
Stored size: 907 Bytes
Contents
module PhcdevworksAccounts class User < ApplicationRecord # Autogenerate Organization ID before_create :phcdevworks_generate_org_id # User Gravatar Support include Gravtastic gravtastic # Add Users Roles enum role: [:user, :editor, :admin] after_initialize :phcdevworks_set_default_role # Include default devise modules. Others available are: # :trackable, :confirmable, :lockable and :omniauthable devise :database_authenticatable, :registerable, :recoverable, :rememberable, :validatable, :timeoutable private # Autogenerate User Organization ID def phcdevworks_generate_org_id self.org_id = SecureRandom.hex(5) end # First Signup Admin and Rest Default to User def phcdevworks_set_default_role if User.all.count < 1 self.role ||= :admin elsif self.role ||= :user end end end end
Version data entries
38 entries across 38 versions & 1 rubygems