diff options
author | Pratik Naik <pratiknaik@gmail.com> | 2009-03-12 15:31:24 +0000 |
---|---|---|
committer | Pratik Naik <pratiknaik@gmail.com> | 2009-03-12 15:31:24 +0000 |
commit | 53744c543880999a7ad3f1e026875df3283978f1 (patch) | |
tree | 8d01e0c15a384a46db176ad8d5cdd0bd6c9024a8 /activerecord/lib/active_record/autosave_association.rb | |
parent | 053afbe3bd26d627ee04a0aaa73554b7be422f05 (diff) | |
parent | 47bdf3bf40ec17e1f8ca1c0e3d7f697d0c4cd1bf (diff) | |
download | rails-53744c543880999a7ad3f1e026875df3283978f1.tar.gz rails-53744c543880999a7ad3f1e026875df3283978f1.tar.bz2 rails-53744c543880999a7ad3f1e026875df3283978f1.zip |
Merge commit 'mainstream/master'
Conflicts:
actionpack/lib/action_view/helpers/text_helper.rb
activesupport/lib/active_support/inflector.rb
Diffstat (limited to 'activerecord/lib/active_record/autosave_association.rb')
-rw-r--r-- | activerecord/lib/active_record/autosave_association.rb | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/autosave_association.rb b/activerecord/lib/active_record/autosave_association.rb index 1c3d0567c1..741aa2acbe 100644 --- a/activerecord/lib/active_record/autosave_association.rb +++ b/activerecord/lib/active_record/autosave_association.rb @@ -283,7 +283,7 @@ module ActiveRecord if records = associated_records_to_validate_or_save(association, @new_record_before_save, autosave) records.each do |record| if autosave && record.marked_for_destruction? - record.destroy + association.destroy(record) elsif @new_record_before_save || record.new_record? if autosave association.send(:insert_record, record, false, false) @@ -310,7 +310,7 @@ module ActiveRecord # This all happens inside a transaction, _if_ the Transactions module is included into # ActiveRecord::Base after the AutosaveAssociation module, which it does by default. def save_has_one_association(reflection) - if association = association_instance_get(reflection.name) + if (association = association_instance_get(reflection.name)) && !association.target.nil? if reflection.options[:autosave] && association.marked_for_destruction? association.destroy elsif new_record? || association.new_record? || association[reflection.primary_key_name] != id || reflection.options[:autosave] |