Browse files

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...
1 parent 78defbb commit a605c441b9588930679888108ba134f01d617872 @wangjohn wangjohn 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 a605c44

Please sign in to comment.