diff options
author | Lance Ivy <lance@cainlevy.net> | 2009-07-11 15:09:09 +0200 |
---|---|---|
committer | Eloy Duran <eloy.de.enige@gmail.com> | 2009-09-12 15:40:45 +0200 |
commit | a44a1257d879311d88c2d10c366ab0d6561f903a (patch) | |
tree | e61e24e8dfbd243dfc9b9aa59dbea8f7956b4f86 /activerecord/lib/active_record | |
parent | bcd0ef710ec6d2cc6b880c39de0dfacc07df85e4 (diff) | |
download | rails-a44a1257d879311d88c2d10c366ab0d6561f903a.tar.gz rails-a44a1257d879311d88c2d10c366ab0d6561f903a.tar.bz2 rails-a44a1257d879311d88c2d10c366ab0d6561f903a.zip |
Don't cascade autosave validation to destroyed children. [#2761 state:resolved]
Signed-off-by: Eloy Duran <eloy.de.enige@gmail.com>
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r-- | activerecord/lib/active_record/autosave_association.rb | 2 | ||||
-rwxr-xr-x | activerecord/lib/active_record/base.rb | 5 |
2 files changed, 7 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/autosave_association.rb b/activerecord/lib/active_record/autosave_association.rb index c1bc8423a9..ebd47ec634 100644 --- a/activerecord/lib/active_record/autosave_association.rb +++ b/activerecord/lib/active_record/autosave_association.rb @@ -245,6 +245,8 @@ module ActiveRecord # the parent, <tt>self</tt>, if it wasn't. Skips any <tt>:autosave</tt> # enabled records if they're marked_for_destruction?. def association_valid?(reflection, association) + return true if association.destroyed? + unless valid = association.valid? if reflection.options[:autosave] unless association.marked_for_destruction? diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb index afa4185c60..2f6e3e8ffd 100755 --- a/activerecord/lib/active_record/base.rb +++ b/activerecord/lib/active_record/base.rb @@ -2813,6 +2813,11 @@ module ActiveRecord #:nodoc: @attributes.frozen? end + # Returns +true+ if the record has been destroyed. + def destroyed? + @destroyed + end + # Returns duplicated record with unfreezed attributes. def dup obj = super |