aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--activerecord/lib/active_record/associations/collection_association.rb2
-rw-r--r--activerecord/test/cases/associations/inverse_associations_test.rb2
2 files changed, 1 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/associations/collection_association.rb b/activerecord/lib/active_record/associations/collection_association.rb
index 79e626f67e..2a00ac1386 100644
--- a/activerecord/lib/active_record/associations/collection_association.rb
+++ b/activerecord/lib/active_record/associations/collection_association.rb
@@ -83,7 +83,7 @@ module ActiveRecord
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)
diff --git a/activerecord/test/cases/associations/inverse_associations_test.rb b/activerecord/test/cases/associations/inverse_associations_test.rb
index 89d2876c6c..85d0ad0aa1 100644
--- a/activerecord/test/cases/associations/inverse_associations_test.rb
+++ b/activerecord/test/cases/associations/inverse_associations_test.rb
@@ -305,7 +305,6 @@ class InverseHasManyTests < ActiveRecord::TestCase
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 @@ class InverseHasManyTests < ActiveRecord::TestCase
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