Skip to content

Commit 5576ca2

Browse files
authored
Merge pull request rails#43612 from MaxLap/patch-1
Add record class to error message
2 parents 6e16942 + d67936c commit 5576ca2

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

activerecord/lib/active_record/persistence.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1076,7 +1076,8 @@ def verify_readonly_attribute(name)
10761076

10771077
def _raise_record_not_destroyed
10781078
@_association_destroy_exception ||= nil
1079-
raise @_association_destroy_exception || RecordNotDestroyed.new("Failed to destroy the record", self)
1079+
key = self.class.primary_key
1080+
raise @_association_destroy_exception || RecordNotDestroyed.new("Failed to destroy #{self.class} with #{key}=#{send(key)}", self)
10801081
ensure
10811082
@_association_destroy_exception = nil
10821083
end

activerecord/test/cases/associations/has_many_associations_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2793,7 +2793,7 @@ def test_association_with_rewhere_doesnt_set_inverse_instance_key
27932793
end
27942794

27952795
assert_equal [original_child], car.reload.failed_bulbs
2796-
assert_equal "Failed to destroy the record", error.message
2796+
assert_equal "Failed to destroy FailedBulb with #{FailedBulb.primary_key}=#{original_child.id}", error.message
27972797
end
27982798

27992799
test "updates counter cache when default scope is given" do

0 commit comments

Comments
 (0)