Sha256: a20d80f5508f8437b48eb1e29b6ca40d429fcfbf7e1178cb7b608f5f56a29e11

Contents?: true

Size: 958 Bytes

Versions: 9

Compression:

Stored size: 958 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 :user_group
  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

9 entries across 9 versions & 1 rubygems

Version Path
enju_purchase_request-0.0.12 spec/dummy/app/models/user.rb
enju_purchase_request-0.0.10 spec/dummy/app/models/user.rb
enju_purchase_request-0.0.9 spec/dummy/app/models/user.rb
enju_purchase_request-0.0.8 spec/dummy/app/models/user.rb
enju_purchase_request-0.0.7 spec/dummy/app/models/user.rb
enju_purchase_request-0.0.6 spec/dummy/app/models/user.rb
enju_purchase_request-0.0.5 spec/dummy/app/models/user.rb
enju_purchase_request-0.0.4 spec/dummy/app/models/user.rb
enju_purchase_request-0.0.3 spec/dummy/app/models/user.rb