aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2006-08-20 05:23:34 +0000
committerJeremy Kemper <jeremy@bitsweat.net>2006-08-20 05:23:34 +0000
commit70577d0dcab2f1756e05c98565acf525e55dc51f (patch)
tree96dfe26e412aa81563ef56d3ac07e509488bae05 /activerecord/lib
parente96c58224c31c63b023b7f71e8f3ada440eb2fa8 (diff)
downloadrails-70577d0dcab2f1756e05c98565acf525e55dc51f.tar.gz
rails-70577d0dcab2f1756e05c98565acf525e55dc51f.tar.bz2
rails-70577d0dcab2f1756e05c98565acf525e55dc51f.zip
Pushing a record onto a has_many :through sets the association's foreign key to the associate's primary key and adds it to the correct association. Closes #5829.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4792 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/lib')
-rw-r--r--activerecord/lib/active_record/associations/has_many_through_association.rb3
1 files changed, 2 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/associations/has_many_through_association.rb b/activerecord/lib/active_record/associations/has_many_through_association.rb
index 0257b1857d..1962dc77ff 100644
--- a/activerecord/lib/active_record/associations/has_many_through_association.rb
+++ b/activerecord/lib/active_record/associations/has_many_through_association.rb
@@ -59,7 +59,8 @@ module ActiveRecord
raise_on_type_mismatch(associate)
raise ActiveRecord::HasManyThroughCantAssociateNewRecords.new(@owner, through) unless associate.respond_to?(:new_record?) && !associate.new_record?
- @target << klass.with_scope(:create => construct_join_attributes(associate)) { klass.create! }
+ @owner.send(@reflection.through_reflection.name).proxy_target << klass.with_scope(:create => construct_join_attributes(associate)) { klass.create! }
+ @target << associate
end
end