3
class Company < ActiveRecord::Base
8
has_many :clients, :order => "id", :dependent => :destroy
9
has_many :clients_sorted_desc, :class_name => "Client", :order => "id DESC"
10
has_many :clients_of_firm, :foreign_key => "client_of", :class_name => "Client", :order => "id"
11
has_many :clients_like_ms, :conditions => "name = 'Microsoft'", :class_name => "Client", :order => "id"
12
has_many :clients_using_sql, :class_name => "Client", :finder_sql => 'SELECT * FROM companies WHERE client_of = #{id}'
14
has_one :account, :class_name => 'MyApplication::Billing::Account', :dependent => :destroy
17
class Client < Company
18
belongs_to :firm, :foreign_key => "client_of"
19
belongs_to :firm_with_other_name, :class_name => "Firm", :foreign_key => "client_of"
21
class Contact < ActiveRecord::Base; end
24
class Developer < ActiveRecord::Base
25
has_and_belongs_to_many :projects
26
validates_length_of :name, :within => (3..20)
29
class Project < ActiveRecord::Base
30
has_and_belongs_to_many :developers
36
class Firm < ActiveRecord::Base
37
self.table_name = 'companies'
41
class Firm < ActiveRecord::Base
42
self.table_name = 'companies'
46
class Account < ActiveRecord::Base
47
with_options(:foreign_key => :firm_id) do |i|
48
i.belongs_to :firm, :class_name => 'MyApplication::Business::Firm'
49
i.belongs_to :qualified_billing_firm, :class_name => 'MyApplication::Billing::Firm'
50
i.belongs_to :unqualified_billing_firm, :class_name => 'Firm'
51
i.belongs_to :nested_qualified_billing_firm, :class_name => 'MyApplication::Billing::Nested::Firm'
52
i.belongs_to :nested_unqualified_billing_firm, :class_name => 'Nested::Firm'
57
errors.add_on_empty "credit_limit"