diff options
author | Fabian Schwahn <fabian.schwahn@gmail.com> | 2017-04-20 10:59:20 +0200 |
---|---|---|
committer | Fabian Schwahn <fabian.schwahn@gmail.com> | 2017-04-20 11:09:53 +0200 |
commit | dc47c2be4eb28a92e7fc0f2195b81ed453b8245d (patch) | |
tree | cb808a6196bb6d261fbbc3c941109535f04cf2d5 /activerecord/lib/active_record | |
parent | 809421811440391d596c63fb65e2a4a0424027ef (diff) | |
download | rails-dc47c2be4eb28a92e7fc0f2195b81ed453b8245d.tar.gz rails-dc47c2be4eb28a92e7fc0f2195b81ed453b8245d.tar.bz2 rails-dc47c2be4eb28a92e7fc0f2195b81ed453b8245d.zip |
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).
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r-- | activerecord/lib/active_record/reflection.rb | 7 |
1 files changed, 3 insertions, 4 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. |