diff options
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/lib/active_record/reflection.rb | 7 | ||||
-rw-r--r-- | activerecord/test/cases/associations/inverse_associations_test.rb | 8 |
2 files changed, 5 insertions, 10 deletions
diff --git a/activerecord/lib/active_record/reflection.rb b/activerecord/lib/active_record/reflection.rb index 24ca8b0be4..c7472372ab 100644 --- a/activerecord/lib/active_record/reflection.rb +++ b/activerecord/lib/active_record/reflection.rb @@ -567,7 +567,7 @@ module ActiveRecord end VALID_AUTOMATIC_INVERSE_MACROS = [:has_many, :has_one, :belongs_to] - INVALID_AUTOMATIC_INVERSE_OPTIONS = [:conditions, :through, :polymorphic, :foreign_key] + INVALID_AUTOMATIC_INVERSE_OPTIONS = [:conditions, :through, :foreign_key] def add_as_source(seed) seed @@ -640,9 +640,8 @@ module ActiveRecord # us from being able to guess the inverse automatically. First, the # <tt>inverse_of</tt> option cannot be set to false. Second, we must # have <tt>has_many</tt>, <tt>has_one</tt>, <tt>belongs_to</tt> associations. - # Third, we must not have options such as <tt>:polymorphic</tt> or - # <tt>:foreign_key</tt> which prevent us from correctly guessing the - # inverse association. + # Third, we must not have options such as <tt>:foreign_key</tt> + # which prevent us from correctly guessing the inverse association. # # Anything with a scope can additionally ruin our attempt at finding an # inverse, so we exclude reflections with scopes. diff --git a/activerecord/test/cases/associations/inverse_associations_test.rb b/activerecord/test/cases/associations/inverse_associations_test.rb index 287b3e9ebc..cf51f1009f 100644 --- a/activerecord/test/cases/associations/inverse_associations_test.rb +++ b/activerecord/test/cases/associations/inverse_associations_test.rb @@ -116,15 +116,11 @@ class AutomaticInverseFindingTests < ActiveRecord::TestCase assert !club_reflection.has_inverse?, "A has_many_through association should not find an inverse automatically" end - def test_polymorphic_relationships_should_still_not_have_inverses_when_non_polymorphic_relationship_has_the_same_name + def test_polymorphic_has_one_should_find_inverse_automatically man_reflection = Man.reflect_on_association(:polymorphic_face_without_inverse) - face_reflection = Face.reflect_on_association(:man) - - assert_respond_to face_reflection, :has_inverse? - assert face_reflection.has_inverse?, "For this test, the non-polymorphic association must have an inverse" assert_respond_to man_reflection, :has_inverse? - assert !man_reflection.has_inverse?, "The target of a polymorphic association should not find an inverse automatically" + assert man_reflection.has_inverse? end end |