Sha256: 7e55bb2c8de03224a5e8694a5b4a52f6d43cda42349f0aac06e0cde118f6b7a1

Contents?: true

Size: 853 Bytes

Versions: 5

Compression:

Stored size: 853 Bytes

Contents

module InvoiceBar
  class Contact < ActiveRecord::Base
    attr_accessible :bank_account, :tax_id2, :email, :tax_id, :name, :phone, :web

    validates :name, presence: true

    validates :tax_id,  length: { in: 2..8 },   allow_blank: true
    validates :tax_id2, 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
      %w( name tax_id email phone )
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
invoice_bar-0.0.11 app/models/invoice_bar/contact.rb
invoice_bar-0.0.10 app/models/invoice_bar/contact.rb
invoice_bar-0.0.9 app/models/invoice_bar/contact.rb
invoice_bar-0.0.8 app/models/invoice_bar/contact.rb
invoice_bar-0.0.7 app/models/invoice_bar/contact.rb