diff options
Diffstat (limited to 'activerecord/lib')
-rwxr-xr-x | activerecord/lib/active_record/associations.rb | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/associations.rb b/activerecord/lib/active_record/associations.rb index ffb0d5679b..d0db4469e2 100755 --- a/activerecord/lib/active_record/associations.rb +++ b/activerecord/lib/active_record/associations.rb @@ -445,10 +445,12 @@ module ActiveRecord module_eval do before_save <<-EOF association = instance_variable_get("@#{association_name}") - if not association.nil? and association.new_record? - association.save(true) + if not association.nil? + if association.new_record? + association.save(true) + association.send(:construct_sql) + end self["#{association_class_primary_key_name}"] = association.id - association.send(:construct_sql) end EOF end |