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

Version Path
enju_inter_library_loan-0.1.0.pre9 spec/dummy/app/models/user.rb
enju_inter_library_loan-0.1.0.pre8 spec/dummy/app/models/user.rb
enju_inter_library_loan-0.1.0.pre7 spec/dummy/app/models/user.rb
enju_inter_library_loan-0.1.0.pre6 spec/dummy/app/models/user.rb
enju_inter_library_loan-0.1.0.pre5 spec/dummy/app/models/user.rb
enju_inter_library_loan-0.1.0.pre4 spec/dummy/app/models/user.rb
enju_inter_library_loan-0.1.0.pre3 spec/dummy/app/models/user.rb
enju_inter_library_loan-0.1.0.pre2 spec/dummy/app/models/user.rb
enju_inter_library_loan-0.1.0.pre spec/dummy/app/models/user.rb
enju_inter_library_loan-0.0.6 spec/dummy/app/models/user.rb
enju_inter_library_loan-0.0.5 spec/dummy/app/models/user.rb
enju_inter_library_loan-0.0.4 spec/dummy/app/models/user.rb
enju_inter_library_loan-0.0.3 spec/dummy/app/models/user.rb
enju_inter_library_loan-0.0.2 spec/dummy/app/models/user.rb
enju_inter_library_loan-0.0.1 spec/dummy/app/models/user.rb