Sha256: 60f3310b3ac7dc55efceff7f0ba8828bab5c4efcd9b428e0cd99c524b740cb7e
Contents?: true
Size: 655 Bytes
Versions: 1
Compression:
Stored size: 655 Bytes
Contents
module Storytime class User < ActiveRecord::Base # Include default devise modules. Others available are: # :confirmable, :lockable, :timeoutable and :omniauthable devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable belongs_to :role has_many :posts has_many :pages has_many :media has_many :versions after_create :assign_first_admin def admin? role && role.name == "admin" end def assign_first_admin if User.count == 1 admin_role = Role.find_by(name: "admin") admin_role.users << self end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
storytime-0.0.1 | app/models/storytime/user.rb |