Skip to content
Browse files

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...
1 parent d756525 commit 152c41d524b58951b5b30ca03d1ba8034dd646a9 @sirlantis sirlantis committed
Showing with 1 addition and 1 deletion.
  1. +1 −1 activerecord/lib/active_record/associations/through_association_scope.rb
View
2 activerecord/lib/active_record/associations/through_association_scope.rb
@@ -30,7 +30,7 @@ def construct_conditions
# Associate attributes pointing to owner, quoted.
def construct_quoted_owner_attributes(reflection)
if as = reflection.options[:as]
- { "#{as}_id" => @owner[reflection.active_record_primary_key],
+ { "#{as}_id" => @owner.class.quote_value(@owner[reflection.active_record_primary_key]),
"#{as}_type" => reflection.klass.quote_value(
@owner.class.base_class.name.to_s,
reflection.klass.columns_hash["#{as}_type"]) }

0 comments on commit 152c41d

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