diff options
Diffstat (limited to 'activerecord/lib')
-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 e1a9c54e5d..b69577f8dd 100755 --- a/activerecord/lib/active_record/associations.rb +++ b/activerecord/lib/active_record/associations.rb @@ -1544,12 +1544,12 @@ module ActiveRecord when :destroy, :delete define_method(method_name) do association = send(reflection.name) - association.destroy unless association.nil? + association.send(name) if association end when :nullify define_method(method_name) do association = send(reflection.name) - association.update_attribute(reflection.primary_key_name, nil) unless association.nil? + association.update_attribute(reflection.primary_key_name, nil) if association end else raise ArgumentError, "The :dependent option expects either :destroy, :delete or :nullify (#{reflection.options[:dependent].inspect})" @@ -1570,7 +1570,7 @@ module ActiveRecord method_name = :"belongs_to_dependent_#{name}_for_#{reflection.name}" define_method(method_name) do association = send(reflection.name) - association.destroy unless association.nil? + association.send(name) if association end after_destroy method_name end |