Sha256: 9e4c97a220aed45f1f645613e4a135dd9f6d8d17859316ae362edab427a9695d

Contents?: true

Size: 1.06 KB

Versions: 18

Compression:

Stored size: 1.06 KB

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 :bookmarks, :dependent => :destroy

  def owned_tags_by_solr
    bookmark_ids = bookmarks.collect(&:id)
    if bookmark_ids.empty?
      []
    else
      Tag.bookmarked(bookmark_ids)
    end
  end

  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

18 entries across 18 versions & 1 rubygems

Version Path
enju_bookmark-0.0.20 spec/dummy/app/models/user.rb
enju_bookmark-0.0.19 spec/dummy/app/models/user.rb
enju_bookmark-0.0.18 spec/dummy/app/models/user.rb
enju_bookmark-0.0.17 spec/dummy/app/models/user.rb
enju_bookmark-0.0.16 spec/dummy/app/models/user.rb
enju_bookmark-0.0.15 spec/dummy/app/models/user.rb
enju_bookmark-0.0.14 spec/dummy/app/models/user.rb
enju_bookmark-0.0.13 spec/dummy/app/models/user.rb
enju_bookmark-0.0.12 spec/dummy/app/models/user.rb
enju_bookmark-0.0.11 spec/dummy/app/models/user.rb
enju_bookmark-0.0.10 spec/dummy/app/models/user.rb
enju_bookmark-0.0.9 spec/dummy/app/models/user.rb
enju_bookmark-0.0.8 spec/dummy/app/models/user.rb
enju_bookmark-0.0.7 spec/dummy/app/models/user.rb
enju_bookmark-0.0.6 spec/dummy/app/models/user.rb
enju_bookmark-0.0.5 spec/dummy/app/models/user.rb
enju_bookmark-0.0.4 spec/dummy/app/models/user.rb
enju_bookmark-0.0.3 spec/dummy/app/models/user.rb