diff options
author | Jon Leighton <j@jonathanleighton.com> | 2010-12-15 23:27:15 +0000 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2010-12-15 17:50:14 -0800 |
commit | 14b880fd035fcdf807051398674c9aa89bd3b4d3 (patch) | |
tree | 6f80999405dea289391abfdf4552cea407d9cd45 /activerecord/test/models | |
parent | 09ddca67acbb88e2fdd7300670839cbf647b2694 (diff) | |
download | rails-14b880fd035fcdf807051398674c9aa89bd3b4d3.tar.gz rails-14b880fd035fcdf807051398674c9aa89bd3b4d3.tar.bz2 rails-14b880fd035fcdf807051398674c9aa89bd3b4d3.zip |
Fix various issues with the :primary_key option in :through associations [#2421 state:resolved]
Diffstat (limited to 'activerecord/test/models')
-rw-r--r-- | activerecord/test/models/categorization.rb | 3 | ||||
-rw-r--r-- | activerecord/test/models/post.rb | 10 |
2 files changed, 13 insertions, 0 deletions
diff --git a/activerecord/test/models/categorization.rb b/activerecord/test/models/categorization.rb index b3fc29fa15..fdb0a11540 100644 --- a/activerecord/test/models/categorization.rb +++ b/activerecord/test/models/categorization.rb @@ -2,6 +2,9 @@ class Categorization < ActiveRecord::Base belongs_to :post belongs_to :category belongs_to :author + + belongs_to :author_using_custom_pk, :class_name => 'Author', :foreign_key => :author_id, :primary_key => :author_address_extra_id + has_many :authors_using_custom_pk, :class_name => 'Author', :foreign_key => :id, :primary_key => :category_id end class SpecialCategorization < ActiveRecord::Base diff --git a/activerecord/test/models/post.rb b/activerecord/test/models/post.rb index 164b499bf0..974e87d2bf 100644 --- a/activerecord/test/models/post.rb +++ b/activerecord/test/models/post.rb @@ -69,6 +69,16 @@ class Post < ActiveRecord::Base has_many :categorizations, :foreign_key => :category_id has_many :authors, :through => :categorizations + has_many :categorizations_using_author_id, :primary_key => :author_id, :foreign_key => :post_id, :class_name => 'Categorization' + has_many :authors_using_author_id, :through => :categorizations_using_author_id, :source => :author + + has_many :taggings_using_author_id, :primary_key => :author_id, :as => :taggable, :class_name => 'Tagging' + has_many :tags_using_author_id, :through => :taggings_using_author_id, :source => :tag + + has_many :standard_categorizations, :class_name => 'Categorization', :foreign_key => :post_id + has_many :author_using_custom_pk, :through => :standard_categorizations + has_many :authors_using_custom_pk, :through => :standard_categorizations + has_many :readers has_many :readers_with_person, :include => :person, :class_name => "Reader" has_many :people, :through => :readers |