Sha256: a175b20df03cca6c5103ce4b22e43c655beda20f26eb0ce024e87cfb1d7bd0b0

Contents?: true

Size: 1.41 KB

Versions: 6

Compression:

Stored size: 1.41 KB

Contents

# encoding: utf-8

module InvoiceBar
  class User < ActiveRecord::Base  
    attr_accessible :name, :email, :ic, :phone, :web, :administrator
  
    validates :name,  :presence => true
    validates :email, :presence => true, :uniqueness => true
    validates :ic,    :presence => true, :numericality => true, :length => { :in => 2..8 }
    
    # Sorcery auth
    authenticates_with_sorcery!

    attr_accessible :password, :crypted_password, :salt,
                    :remember_me_token, :remember_me_token_expires_at,
                    :reset_password_email_sent_at, :reset_password_token,
                    :reset_password_token_expires_at

    # Associations
    attr_accessible :address_attributes
  
    delegate :city, :city_part, :extra_address_line, :postcode, :street, :street_number, :to => :address
  
    has_many :accounts,           :dependent => :destroy
    has_many :contacts,           :dependent => :destroy
    has_many :invoices,           :dependent => :destroy
    has_many :invoice_templates,  :dependent => :destroy
    has_many :receipts,           :dependent => :destroy
    has_many :receipt_templates,  :dependent => :destroy
  
    has_one :address, :as => :addressable, :dependent => :destroy 
  
    accepts_nested_attributes_for :address, :allow_destroy => true
    
    # Search
    include InvoiceBar::Searchable
    
    def self.searchable_fields
      ['name', 'ic', 'email', 'phone']
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
invoice_bar-0.0.6 app/models/invoice_bar/user.rb
invoice_bar-0.0.5 app/models/invoice_bar/user.rb
invoice_bar-0.0.4 app/models/invoice_bar/user.rb
invoice_bar-0.0.3 app/models/invoice_bar/user.rb
invoice_bar-0.0.2 app/models/invoice_bar/user.rb
invoice_bar-0.0.1 app/models/invoice_bar/user.rb