• F
    Fix dependence on has_one/belongs_to relationships · a286c32c
    Fernando Gorodscy 提交于
    When a class has a belongs_to or has_one relationship with dependent: :destroy
    option enabled, objects of this class should not be deleted if it's dependents
    cannot be deleted.
    
    Example:
    
        class Parent
          has_one :child, dependent: :destroy
        end
    
        class Child
          belongs_to :parent, inverse_of: :child
          before_destroy { throw :abort }
        end
    
        c = Child.create
        p = Parent.create(child: c)
    
        p.destroy
    
        p.destroyed? # expected: false; actual: true;
    
    Fixes #32022
    a286c32c
belongs_to_associations_test.rb 36.9 KB