1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/activerecord/test
Brian Thomas Storti 5aab0c0538 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 commit, the same code would raise a `RecordNotDestroyed`
exception, keeping the `post` with the same `comment`.
2013-11-25 19:30:07 -02:00
..
active_record/connection_adapters Ensure disconnecting or reconnecting resets the transaction state 2012-09-15 00:03:04 +01:00
assets
cases Raise RecordNotDestroyed when children can't be replaced 2013-11-25 19:30:07 -02:00
fixtures Extend ActiveRecord::Base#cache_key to take an optional list of timestamp attributes of which the highest will be used. 2013-11-02 16:05:19 -07:00
migrations Preserve magic comments and content encoding of copied migrations. 2013-03-09 15:38:02 +09:00
models Raise RecordNotDestroyed when children can't be replaced 2013-11-25 19:30:07 -02:00
schema Use 1.9 Hash syntax consistently 2013-11-05 08:13:37 -05:00
support Revert "Fix annoy warning, when executing testcase." 2012-11-30 12:07:55 +04:00
.gitignore
config.example.yml
config.rb