From 5aab0c053832ded70a3a4b58cb97f8f8bba796ba Mon Sep 17 00:00:00 2001 From: Brian Thomas Storti Date: Sat, 23 Nov 2013 09:24:52 -0200 Subject: 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`. --- activerecord/CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'activerecord/CHANGELOG.md') diff --git a/activerecord/CHANGELOG.md b/activerecord/CHANGELOG.md index 1114cdb94d..8317adfeb2 100644 --- a/activerecord/CHANGELOG.md +++ b/activerecord/CHANGELOG.md @@ -1042,4 +1042,10 @@ *Slava Markevich* +* Raise `ActiveRecord::RecordNotDestroyed` when a replaced child marked with `dependent: destroy` fails to be destroyed. + + Fix #12812 + + *Brian Thomas Storti* + Please check [4-0-stable](https://github.com/rails/rails/blob/4-0-stable/activerecord/CHANGELOG.md) for previous changes. -- cgit v1.2.3 From 09f941c507455e5523cd2d990117c1fcf4f0ab9c Mon Sep 17 00:00:00 2001 From: Brian Thomas Storti Date: Mon, 25 Nov 2013 23:17:31 -0200 Subject: move changelog entry to the top --- activerecord/CHANGELOG.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'activerecord/CHANGELOG.md') diff --git a/activerecord/CHANGELOG.md b/activerecord/CHANGELOG.md index 8317adfeb2..bce288aefb 100644 --- a/activerecord/CHANGELOG.md +++ b/activerecord/CHANGELOG.md @@ -1,3 +1,9 @@ +* Raise `ActiveRecord::RecordNotDestroyed` when a replaced child marked with `dependent: destroy` fails to be destroyed. + + Fix #12812 + + *Brian Thomas Storti* + * Fix validation on uniqueness of empty association. *Evgeny Li* @@ -1042,10 +1048,4 @@ *Slava Markevich* -* Raise `ActiveRecord::RecordNotDestroyed` when a replaced child marked with `dependent: destroy` fails to be destroyed. - - Fix #12812 - - *Brian Thomas Storti* - Please check [4-0-stable](https://github.com/rails/rails/blob/4-0-stable/activerecord/CHANGELOG.md) for previous changes. -- cgit v1.2.3