aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record
diff options
context:
space:
mode:
authorRafael França <rafaelmfranca@gmail.com>2019-06-24 13:59:15 -0400
committerGitHub <noreply@github.com>2019-06-24 13:59:15 -0400
commitb65f88652f835093030bf65b9e31e727ba58a6de (patch)
tree40e6e2afb2f230e31fd55b9828423265bb857682 /activerecord/lib/active_record
parent58256db50750781016f5ea6d2dd6cbc72096062b (diff)
parentbbcd707aefe5da137137a8deb13908ec9a7db77d (diff)
downloadrails-b65f88652f835093030bf65b9e31e727ba58a6de.tar.gz
rails-b65f88652f835093030bf65b9e31e727ba58a6de.tar.bz2
rails-b65f88652f835093030bf65b9e31e727ba58a6de.zip
Merge pull request #36210 from vishaltelangre/raise-record-invalid-when-associations-fail-to-save-due-to-uniqueness-failure
Fix: ActiveRecord::RecordInvalid is not raised when an associated record fails to #save! due to uniqueness validation failure
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r--activerecord/lib/active_record/autosave_association.rb2
1 files changed, 1 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/autosave_association.rb b/activerecord/lib/active_record/autosave_association.rb
index a7709b444d..94d8134b55 100644
--- a/activerecord/lib/active_record/autosave_association.rb
+++ b/activerecord/lib/active_record/autosave_association.rb
@@ -409,7 +409,7 @@ module ActiveRecord
saved = record.save(validate: false)
end
- raise ActiveRecord::Rollback unless saved
+ raise(RecordInvalid.new(association.owner)) unless saved
end
end
end