Sha256: 76f799e654d2a8ed551c914b77d5e45ba330b1a41789c552b403c1f5109980b0
Contents?: true
Size: 1.08 KB
Versions: 1
Compression:
Stored size: 1.08 KB
Contents
class User < ActiveRecord::Base # Include default devise modules. Others available are: # :token_authenticatable, :confirmable, :lockable and :timeoutable devise :database_authenticatable, :recoverable, :rememberable, :trackable, :validatable # Setup accessible (or protected) attributes for your model attr_accessible :email, :password, :password_confirmation, :remember_me # Tenancy belongs_to :tenant # Authorization roles has_and_belongs_to_many :roles, :autosave => true scope :by_role, lambda{|role| include(:roles).where(:name => role)} attr_accessible :role_texts def role?(role) !!self.roles.find_by_name(role.to_s) end def role_texts roles.map{|role| role.name} end def role_texts=(role_names) self.roles = Role.where(:name => role_names) end # Associations belongs_to :person validates_presence_of :person accepts_nested_attributes_for :person attr_accessible :person, :person_attributes # Shortcuts def current_company person.try(:employers).try(:first) end # Helpers def to_s person.try(:to_s) || "" end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
bookyt-0.0.1 | app/models/user.rb |