Skip to content
Browse files

Merge pull request #10036 from wangjohn/norecord_error_message_consis…

…tency_issues

Updated the error message for find to stay consistent across Rails
  • Loading branch information...
2 parents 78defbb + a605c44 commit abad4f7049040f3b3f29b04f27f0a3fab3065060 @rafaelfranca rafaelfranca committed Apr 1, 2013
View
2 activerecord/lib/active_record/associations/collection_association.rb
@@ -83,7 +83,7 @@ def find(*args)
find_by_scan(*args)
elsif options[:inverse_of]
args = args.flatten
- raise RecordNotFound, "Must specify an id to find" if args.blank?
+ raise RecordNotFound, "Couldn't find #{scope.klass.name} without an ID" if args.blank?
result = find_by_scan(*args)
View
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
def test_raise_record_not_found_error_when_invalid_ids_are_passed
man = Man.create!
- interest = Interest.create!(man: man)
invalid_id = 2394823094892348920348523452345
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
def test_raise_record_not_found_error_when_no_ids_are_passed
man = Man.create!
- interest = Interest.create!(man: man)
assert_raise(ActiveRecord::RecordNotFound) { man.interests.find() }
end

0 comments on commit abad4f7

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