Sha256: c6ec0279a91119fe9d02c237fc3855a5fffa6a71da04762954417dcf14ce5ca0

Contents?: true

Size: 946 Bytes

Versions: 6

Compression:

Stored size: 946 Bytes

Contents

# encoding: utf-8

module InvoiceBar
  class Contact < ActiveRecord::Base
    attr_accessible :bank_account, :dic, :email, :ic, :name, :phone, :web
  
    validates :name, :presence => true
  
    validates :ic,  :length => { :in => 2..8 },   :allow_blank => true#, :numericality => true
    validates :dic, :length => { :in => 4..14 },  :allow_blank => true
  
    # Associations
    attr_accessible :user_id, :address_attributes
  
    delegate :city, :city_part, :extra_address_line, :postcode, :street, :street_number,
             :to => :address#, :prefix => true
  
    has_one :address, :as => :addressable, :dependent => :destroy
    belongs_to :user
  
    accepts_nested_attributes_for :address, :allow_destroy => true, :reject_if => :all_blank
  
    validates :user_id, :presence => 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/contact.rb
invoice_bar-0.0.5 app/models/invoice_bar/contact.rb
invoice_bar-0.0.4 app/models/invoice_bar/contact.rb
invoice_bar-0.0.3 app/models/invoice_bar/contact.rb
invoice_bar-0.0.2 app/models/invoice_bar/contact.rb
invoice_bar-0.0.1 app/models/invoice_bar/contact.rb