Skip to content
This repository
Browse code

Updated the error message for +find+ on an inverse_of association

so that it is consistent with the error thrown for +find+ without an
inverse_of association.
  • Loading branch information...
commit a605c441b9588930679888108ba134f01d617872 1 parent 78defbb
John J. Wang wangjohn authored
2  activerecord/lib/active_record/associations/collection_association.rb
@@ -83,7 +83,7 @@ def find(*args)
83 83 find_by_scan(*args)
84 84 elsif options[:inverse_of]
85 85 args = args.flatten
86   - raise RecordNotFound, "Must specify an id to find" if args.blank?
  86 + raise RecordNotFound, "Couldn't find #{scope.klass.name} without an ID" if args.blank?
87 87
88 88 result = find_by_scan(*args)
89 89
2  activerecord/test/cases/associations/inverse_associations_test.rb
@@ -305,7 +305,6 @@ def test_parent_instance_should_find_child_instance_using_child_instance_id_when
305 305
306 306 def test_raise_record_not_found_error_when_invalid_ids_are_passed
307 307 man = Man.create!
308   - interest = Interest.create!(man: man)
309 308
310 309 invalid_id = 2394823094892348920348523452345
311 310 assert_raise(ActiveRecord::RecordNotFound) { man.interests.find(invalid_id) }
@@ -316,7 +315,6 @@ def test_raise_record_not_found_error_when_invalid_ids_are_passed
316 315
317 316 def test_raise_record_not_found_error_when_no_ids_are_passed
318 317 man = Man.create!
319   - interest = Interest.create!(man: man)
320 318
321 319 assert_raise(ActiveRecord::RecordNotFound) { man.interests.find() }
322 320 end

0 comments on commit a605c44

Please sign in to comment.
Something went wrong with that request. Please try again.