diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2006-10-08 06:45:32 +0000 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2006-10-08 06:45:32 +0000 |
commit | 0c3c131f3b9a82d3e2f36b2930c3437c9f821b6d (patch) | |
tree | 4cd7f72d3f4f6b5197185b3efa987ecd0cd08097 /activerecord/lib/active_record/associations | |
parent | 6c0609fafb387f2f61ba9eb9754c31bdebeb46ec (diff) | |
download | rails-0c3c131f3b9a82d3e2f36b2930c3437c9f821b6d.tar.gz rails-0c3c131f3b9a82d3e2f36b2930c3437c9f821b6d.tar.bz2 rails-0c3c131f3b9a82d3e2f36b2930c3437c9f821b6d.zip |
The has_many create method works with polymorphic associations. Closes #6361.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5230 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/lib/active_record/associations')
-rw-r--r-- | activerecord/lib/active_record/associations/has_many_association.rb | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/activerecord/lib/active_record/associations/has_many_association.rb b/activerecord/lib/active_record/associations/has_many_association.rb index d0af68eea7..3cd6e5d716 100644 --- a/activerecord/lib/active_record/associations/has_many_association.rb +++ b/activerecord/lib/active_record/associations/has_many_association.rb @@ -91,20 +91,21 @@ module ActiveRecord @reflection.klass.find(*args) end end - + protected def method_missing(method, *args, &block) if @target.respond_to?(method) || (!@reflection.klass.respond_to?(method) && Class.respond_to?(method)) super else + create_scoping = {} + set_belongs_to_association_for(create_scoping) + @reflection.klass.with_scope( + :create => create_scoping, :find => { :conditions => @finder_sql, :joins => @join_sql, :readonly => false - }, - :create => { - @reflection.primary_key_name => @owner.id } ) do @reflection.klass.send(method, *args, &block) |