rails/rails — pull request #13042 by brianstorti (2013-11-25 21:35:04+00:00)
Title: Raise `RecordNotDestroyed` when children can't be replaced

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 change, the same code would raise a `RecordNotDestroyed` exception, keeping the `post` with the same `comment`.