diff options
author | Tobias Lütke <tobias.luetke@gmail.com> | 2005-12-20 20:32:47 +0000 |
---|---|---|
committer | Tobias Lütke <tobias.luetke@gmail.com> | 2005-12-20 20:32:47 +0000 |
commit | 1d2c6ee8f3f7e4b6881f30e6b53582738c2b3ace (patch) | |
tree | 2928e565d896bfd8e0e0f8cb3829a8c4a012359a /activerecord/test | |
parent | 1235d26bfbc99a7b7466bddb8ff69eecc585d27f (diff) | |
download | rails-1d2c6ee8f3f7e4b6881f30e6b53582738c2b3ace.tar.gz rails-1d2c6ee8f3f7e4b6881f30e6b53582738c2b3ace.tar.bz2 rails-1d2c6ee8f3f7e4b6881f30e6b53582738c2b3ace.zip |
added :piggyback option to has_many :through relationships to pick up values from the join table as needed
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3323 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/associations_join_model_test.rb | 4 | ||||
-rw-r--r-- | activerecord/test/fixtures/category.rb | 2 |
2 files changed, 5 insertions, 1 deletions
diff --git a/activerecord/test/associations_join_model_test.rb b/activerecord/test/associations_join_model_test.rb index d53a8d98d3..502e4d28c5 100644 --- a/activerecord/test/associations_join_model_test.rb +++ b/activerecord/test/associations_join_model_test.rb @@ -38,5 +38,9 @@ class AssociationsJoinModelTest < Test::Unit::TestCase def test_polymorphic_has_many_going_through_join_model_with_inheritance assert_equal tags(:general), posts(:thinking).tags.first end + + def test_has_many_with_piggyback + assert_equal "2", categories(:sti_test).authors.first.post_id + end end diff --git a/activerecord/test/fixtures/category.rb b/activerecord/test/fixtures/category.rb index 01938d1405..d0e0dfb770 100644 --- a/activerecord/test/fixtures/category.rb +++ b/activerecord/test/fixtures/category.rb @@ -6,7 +6,7 @@ class Category < ActiveRecord::Base end has_many :categorizations - has_many :authors, :through => :categorizations + has_many :authors, :through => :categorizations, :piggyback => [:post_id] end class SpecialCategory < Category |