Permalink
Browse files

Remove unnecessary scoping for creating hm:t join record

  • Loading branch information...
1 parent 50b8398 commit ad28e0037b1d27494b846b1e65db874c37445e91 @lifo lifo committed Aug 10, 2009
Showing with 4 additions and 3 deletions.
  1. +4 −3 activerecord/lib/active_record/associations/has_many_through_association.rb
@@ -65,9 +65,10 @@ def insert_record(record, force = true, validate = true)
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

0 comments on commit ad28e00

Please sign in to comment.