From 3e0a60e4e2316ee696bdcf1c115582f8f450ad07 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Fri, 27 Sep 2013 16:56:49 -0700 Subject: adding a test to demonstrate how to use STI subclasses on the far right side of a hm:t association along with preloading. --- activerecord/test/models/contract.rb | 1 + activerecord/test/models/developer.rb | 2 ++ 2 files changed, 3 insertions(+) (limited to 'activerecord/test/models') diff --git a/activerecord/test/models/contract.rb b/activerecord/test/models/contract.rb index 2cf5aa7a85..cdf7b267b5 100644 --- a/activerecord/test/models/contract.rb +++ b/activerecord/test/models/contract.rb @@ -1,6 +1,7 @@ class Contract < ActiveRecord::Base belongs_to :company belongs_to :developer + belongs_to :firm, :foreign_key => 'company_id' before_save :hi after_save :bye diff --git a/activerecord/test/models/developer.rb b/activerecord/test/models/developer.rb index c8e2be580e..a26de55758 100644 --- a/activerecord/test/models/developer.rb +++ b/activerecord/test/models/developer.rb @@ -38,6 +38,8 @@ class Developer < ActiveRecord::Base has_and_belongs_to_many :special_projects, :join_table => 'developers_projects', :association_foreign_key => 'project_id' has_many :audit_logs + has_many :contracts + has_many :firms, :through => :contracts, :source => :firm scope :jamises, -> { where(:name => 'Jamis') } -- cgit v1.2.3