Skip to content

Instantly share code, notes, and snippets.

@diegorv
Created September 1, 2011 17:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save diegorv/1186738 to your computer and use it in GitHub Desktop.
Save diegorv/1186738 to your computer and use it in GitHub Desktop.
class Client < ActiveRecord::Base
has_many :client_companies, :dependent => :destroy
has_many :contracts , :dependent => :destroy
accepts_nested_attributes_for :client_companies , :allow_destroy => true
end
class ClientCompany < ActiveRecord::Base
belongs_to :client
has_many :client_company_addresses, :dependent => :destroy
has_many :client_company_contacts , :dependent => :destroy
has_many :client_company_employees, :dependent => :destroy
has_many :contracts , :dependent => :destroy
accepts_nested_attributes_for :client_company_addresses , :allow_destroy => true
accepts_nested_attributes_for :client_company_contacts , :allow_destroy => true
accepts_nested_attributes_for :client_company_employees , :allow_destroy => true
end
class ClientCompanyAddress < ActiveRecord::Base
belongs_to :client_company
end
class ClientCompanyContact < ActiveRecord::Base
belongs_to :client_company
end
class ClientCompanyEmployee < ActiveRecord::Base
belongs_to :client_company
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment