aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/models/post.rb
diff options
context:
space:
mode:
authorJon Leighton <j@jonathanleighton.com>2010-12-15 23:27:15 +0000
committerAaron Patterson <aaron.patterson@gmail.com>2010-12-15 17:50:14 -0800
commit14b880fd035fcdf807051398674c9aa89bd3b4d3 (patch)
tree6f80999405dea289391abfdf4552cea407d9cd45 /activerecord/test/models/post.rb
parent09ddca67acbb88e2fdd7300670839cbf647b2694 (diff)
downloadrails-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/post.rb')
-rw-r--r--activerecord/test/models/post.rb10
1 files changed, 10 insertions, 0 deletions
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