From ad28e0037b1d27494b846b1e65db874c37445e91 Mon Sep 17 00:00:00 2001
From: Pratik Naik <pratiknaik@gmail.com>
Date: Mon, 10 Aug 2009 21:20:01 +0100
Subject: Remove unnecessary scoping for creating hm:t join record

---
 .../lib/active_record/associations/has_many_through_association.rb | 7 ++++---
 1 file 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
-- 
cgit v1.2.3