Sha256: 8fc4b76bbc6f9246a6c9f04bd6862706f83b7e8f1acb3584830ee86110e57e06

Contents?: true

Size: 909 Bytes

Versions: 3

Compression:

Stored size: 909 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'

  enju_search_log_user_model

  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

3 entries across 3 versions & 1 rubygems

Version Path
enju_search_log-0.1.0.pre6 spec/dummy/app/models/user.rb
enju_search_log-0.1.0.pre5 spec/dummy/app/models/user.rb
enju_search_log-0.1.0.pre4 spec/dummy/app/models/user.rb