Sha256: 8ff0507779913d9b0c27ca0cd4dab082ba98b9d1aebfde63f19255a6bf88adac
Contents?: true
Size: 1.15 KB
Versions: 1
Compression:
Stored size: 1.15 KB
Contents
class User < ActiveRecord::Base acts_as_authentic self.skip_time_zone_conversion_for_attributes = [] # FIX BUG: https://rails.lighthouseapp.com/projects/8994/tickets/1339-arbase-should-not-be-nuking-its-children-just-because-it-lost-interest validates_presence_of :first_name, :last_name after_save :empty_password # return an anonymous user def self.anonymous User.find_by_email('anonymous@example.com') rescue raise 'No anonymous user found' end def name "#{first_name} #{last_name}" end def roles=(input) write_attribute(:roles, input) if input.is_a? String write_attribute(:roles, input.join(' ')) if input.is_a? Array end def roles (read_attribute(:roles) || []).split(' ') end def has_role?(target_roles) target_roles = [target_roles] if target_roles.is_a? String roles.any? { |role| target_roles.include? role } end # email notifications def deliver_password_reset_instructions! reset_perishable_token! Notifier.deliver_password_reset_instructions(self) end private # after_save def empty_password @password = nil @password_confirmation = nil end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
qcore-1.2.0 | app/models/user.rb |