• B
    Raise `RecordNotDestroyed` when children can't be replaced · 5aab0c05
    Brian Thomas Storti 提交于
    Fixes #12812
    Raise `ActiveRecord::RecordNotDestroyed` when a child marked with
    `dependent: destroy` can't be destroyed.
    
    The following code:
    ```ruby
    class Post < ActiveRecord::Base
      has_many :comments, dependent: :destroy
    end
    
    class Comment < ActiveRecord::Base
      before_destroy do
        return false
      end
    end
    
    post = Post.create!(comments: [Comment.create!])
    post.comments = [Comment.create!]
    ````
    
    would result in a `post` with two `comments`.
    With this commit, the same code would raise a `RecordNotDestroyed`
    exception, keeping the `post` with the same `comment`.
    5aab0c05
可在Tags中查看这些版本中当前仓库的状态.
CHANGELOG.md 28.9 KB