app/models/georgia/user.rb in georgia-0.7.8 vs app/models/georgia/user.rb in georgia-0.8.0

- old
+ new

@@ -1,27 +1,18 @@ module Georgia class User < ActiveRecord::Base devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable - attr_accessible :first_name, :last_name, :email, :password, :password_confirmation, :remember_me, :role_ids + has_many :role_assignments, dependent: :destroy + has_many :roles, through: :role_assignments + has_many :revisions, foreign_key: :revised_by_id - has_and_belongs_to_many :roles, class_name: Georgia::Role - - def has_role? role - return false unless role - @role_names ||= roles.map(&:name) - @role_names.include? role.to_s.titleize + def role_names + @role_names ||= roles.pluck(:name) end - scope :admins, includes(:roles).where(georgia_roles: {name: 'Admin'}) - scope :editors, includes(:roles).where(georgia_roles: {name: 'Editor'}) - def name [first_name, last_name].join(' ') - end - - def roles_names - roles.map(&:name).join(', ') end end end \ No newline at end of file