Sha256: 3881ba20c1a2c49eec6db35d02cb4de51c9b6a2b0c03184557036e19dc8e4034
Contents?: true
Size: 920 Bytes
Versions: 15
Compression:
Stored size: 920 Bytes
Contents
class User < ActiveRecord::Base # Include default devise modules. Others available are: # :token_authenticatable, :encryptable, :confirmable, :lockable, :timeoutable and :omniauthable devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable # Setup accessible (or protected) attributes for your model attr_accessible :email, :password, :password_confirmation, :remember_me has_one :user_has_role has_one :role, :through => :user_has_role belongs_to :required_role, :class_name => 'Role', :foreign_key => 'required_role_id' belongs_to :library, :validate => true def has_role?(role_in_question) return false unless role return true if role.name == role_in_question case role.name when 'Administrator' return true when 'Librarian' return true if role_in_question == 'User' else false end end end
Version data entries
15 entries across 15 versions & 1 rubygems