diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2013-09-27 16:56:49 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2013-09-27 16:56:49 -0700 |
commit | 3e0a60e4e2316ee696bdcf1c115582f8f450ad07 (patch) | |
tree | 9cfa220e983dd7baa633b65704becf1ebfa34a52 /activerecord/test/models | |
parent | f399538f99f9ae3311b694d7e579104ec98b899d (diff) | |
download | rails-3e0a60e4e2316ee696bdcf1c115582f8f450ad07.tar.gz rails-3e0a60e4e2316ee696bdcf1c115582f8f450ad07.tar.bz2 rails-3e0a60e4e2316ee696bdcf1c115582f8f450ad07.zip |
adding a test to demonstrate how to use STI subclasses on the far right
side of a hm:t association along with preloading.
Diffstat (limited to 'activerecord/test/models')
-rw-r--r-- | activerecord/test/models/contract.rb | 1 | ||||
-rw-r--r-- | activerecord/test/models/developer.rb | 2 |
2 files changed, 3 insertions, 0 deletions
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') } |