Sha256: 054ec7510f09d513ab9ee71453df708a80bc5c5782b6cd02d79a9bc6b7e1c116

Contents?: true

Size: 933 Bytes

Versions: 76

Compression:

Stored size: 933 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'
  has_many :purchase_requests
  has_many :order_lists

  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

76 entries across 76 versions & 6 rubygems

Version Path
enju_nii-0.1.0.pre10 spec/dummy/app/models/user.rb
enju_export-0.1.1.pre6 spec/dummy/app/models/user.rb
enju_export-0.1.1.pre5 spec/dummy/app/models/user.rb
enju_inventory-0.1.11.pre9 spec/dummy/app/models/user.rb
enju_nii-0.1.0.pre9 spec/dummy/app/models/user.rb
enju_inventory-0.1.11.pre8 spec/dummy/app/models/user.rb
enju_resource_merge-0.1.0.pre7 spec/dummy/app/models/user.rb
enju_nii-0.1.0.pre8 spec/dummy/app/models/user.rb
enju_export-0.1.1.pre4 spec/dummy/app/models/user.rb
enju_inventory-0.1.11.pre7 spec/dummy/app/models/user.rb
enju_nii-0.1.0.pre7 spec/dummy/app/models/user.rb
enju_nii-0.1.0.pre6 spec/dummy/app/models/user.rb
enju_nii-0.1.0.pre5 spec/dummy/app/models/user.rb
enju_export-0.1.1.pre3 spec/dummy/app/models/user.rb
enju_resource_merge-0.1.0.pre6 spec/dummy/app/models/user.rb
enju_nii-0.1.0.pre4 spec/dummy/app/models/user.rb
enju_inventory-0.1.11.pre6 spec/dummy/app/models/user.rb
enju_nii-0.1.0.pre3 spec/dummy/app/models/user.rb
enju_nii-0.1.0.pre2 spec/dummy/app/models/user.rb
enju_nii-0.1.0.pre spec/dummy/app/models/user.rb