From a605c441b9588930679888108ba134f01d617872 Mon Sep 17 00:00:00 2001 From: wangjohn Date: Mon, 1 Apr 2013 18:16:47 -0400 Subject: 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. --- activerecord/lib/active_record/associations/collection_association.rb | 2 +- activerecord/test/cases/associations/inverse_associations_test.rb | 2 -- 2 files changed, 1 insertion(+), 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 -- cgit v1.2.3