diff options
author | Pratik Naik <pratiknaik@gmail.com> | 2009-08-10 21:20:01 +0100 |
---|---|---|
committer | Pratik Naik <pratiknaik@gmail.com> | 2009-08-10 21:20:01 +0100 |
commit | ad28e0037b1d27494b846b1e65db874c37445e91 (patch) | |
tree | 8051c70056e9b49b74c23047aa06b6e737a38f04 /activerecord | |
parent | 50b83984f111552b91a25b3b1d139f65efcc8e8f (diff) | |
download | rails-ad28e0037b1d27494b846b1e65db874c37445e91.tar.gz rails-ad28e0037b1d27494b846b1e65db874c37445e91.tar.bz2 rails-ad28e0037b1d27494b846b1e65db874c37445e91.zip |
Remove unnecessary scoping for creating hm:t join record
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/lib/active_record/associations/has_many_through_association.rb | 7 |
1 files changed, 4 insertions, 3 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 f09289ada3..829f0ac0c5 100644 --- a/activerecord/lib/active_record/associations/has_many_through_association.rb +++ b/activerecord/lib/active_record/associations/has_many_through_association.rb @@ -65,9 +65,10 @@ module ActiveRecord return false unless record.save(validate) end end - through_reflection = @reflection.through_reflection - klass = through_reflection.klass - @owner.send(@reflection.through_reflection.name).proxy_target << klass.send(:with_scope, :create => construct_join_attributes(record)) { through_reflection.create_association! } + + through_association = @owner.send(@reflection.through_reflection.name) + through_record = through_association.create!(construct_join_attributes(record)) + through_association.proxy_target << through_record end # TODO - add dependent option support |