diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2007-06-21 20:47:26 +0000 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2007-06-21 20:47:26 +0000 |
commit | 989332c734149a7f350a0dd7d483c820552c0267 (patch) | |
tree | caa6fb7ac87cb1ceba2094a76fd5eb6160409a60 /activerecord/lib/active_record | |
parent | 9e4461438f8ce584b635aca35579c36537a340ca (diff) | |
download | rails-989332c734149a7f350a0dd7d483c820552c0267.tar.gz rails-989332c734149a7f350a0dd7d483c820552c0267.tar.bz2 rails-989332c734149a7f350a0dd7d483c820552c0267.zip |
Save associated records only if the association is already loaded. Closes #8713.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7075 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/lib/active_record')
-rwxr-xr-x | activerecord/lib/active_record/associations.rb | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/associations.rb b/activerecord/lib/active_record/associations.rb index d30756b9c7..18f4580f45 100755 --- a/activerecord/lib/active_record/associations.rb +++ b/activerecord/lib/active_record/associations.rb @@ -1100,8 +1100,8 @@ module ActiveRecord after_callback = <<-end_eval association = instance_variable_get("@#{association_name}") - - if association.respond_to?(:loaded?) + + if association.respond_to?(:loaded?) && association.loaded? if @new_record_before_save records_to_save = association else @@ -1111,7 +1111,7 @@ module ActiveRecord association.send(:construct_sql) # reconstruct the SQL queries now that we know the owner's id end end_eval - + # Doesn't use after_save as that would save associations added in after_create/after_update twice after_create(after_callback) after_update(after_callback) |