From dc47c2be4eb28a92e7fc0f2195b81ed453b8245d Mon Sep 17 00:00:00 2001 From: Fabian Schwahn Date: Thu, 20 Apr 2017 10:59:20 +0200 Subject: Remove :polymorphic from INVALID_AUTOMATIC_INVERSE_OPTIONS This makes automatic inverse detection possible for polymorphic :has_one & :has_many possible. This resolves a number of issues, eg. `touch: true` on polymorphic relationships (#16446) and automatically setting inverse associations on newly built objects (#15028, #21843). --- activerecord/lib/active_record/reflection.rb | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'activerecord/lib') 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 # inverse_of option cannot be set to false. Second, we must # have has_many, has_one, belongs_to associations. - # Third, we must not have options such as :polymorphic or - # :foreign_key which prevent us from correctly guessing the - # inverse association. + # Third, we must not have options such as :foreign_key + # 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. -- cgit v1.2.3