Skip to content
This repository
Browse code

Through-association owner's primary key wasn't quoted. Generates inva…

…lid SQL (id = ) if the record wasn't saved yet (i.e. the primary key's value is nil).
  • Loading branch information...
commit 152c41d524b58951b5b30ca03d1ba8034dd646a9 1 parent d756525
Marcel Jackwerth authored May 27, 2011
2  activerecord/lib/active_record/associations/through_association_scope.rb
@@ -30,7 +30,7 @@ def construct_conditions
30 30
       # Associate attributes pointing to owner, quoted.
31 31
       def construct_quoted_owner_attributes(reflection)
32 32
         if as = reflection.options[:as]
33  
-          { "#{as}_id"   => @owner[reflection.active_record_primary_key],
  33
+          { "#{as}_id"   => @owner.class.quote_value(@owner[reflection.active_record_primary_key]),
34 34
             "#{as}_type" => reflection.klass.quote_value(
35 35
               @owner.class.base_class.name.to_s,
36 36
               reflection.klass.columns_hash["#{as}_type"]) }

0 notes on commit 152c41d

Please sign in to comment.
Something went wrong with that request. Please try again.