diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2017-09-27 06:18:23 +0900 |
---|---|---|
committer | Ryuta Kamizono <kamipo@gmail.com> | 2017-09-27 06:26:05 +0900 |
commit | 8d3bf8b66c783419600ad815db8a5405fe573b0b (patch) | |
tree | c057380b30c2f5bca21e0544bd87eaed1b28f5fa /activerecord/lib | |
parent | aa1cf119a63e5327068a5aa16bb6c0a67b35d9e3 (diff) | |
download | rails-8d3bf8b66c783419600ad815db8a5405fe573b0b.tar.gz rails-8d3bf8b66c783419600ad815db8a5405fe573b0b.tar.bz2 rails-8d3bf8b66c783419600ad815db8a5405fe573b0b.zip |
Don't generate `foreign_type` if `options[:polymorphic]` is not given
Because the reflection doesn't have `foreign_type` unless the
association is a polymorphic association.
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/reflection.rb | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/reflection.rb b/activerecord/lib/active_record/reflection.rb index 032df925bf..97adfb4352 100644 --- a/activerecord/lib/active_record/reflection.rb +++ b/activerecord/lib/active_record/reflection.rb @@ -426,7 +426,7 @@ module ActiveRecord def initialize(name, scope, options, active_record) super @type = options[:as] && (options[:foreign_type] || "#{options[:as]}_type") - @foreign_type = options[:foreign_type] || "#{name}_type" + @foreign_type = options[:polymorphic] && (options[:foreign_type] || "#{name}_type") @constructable = calculate_constructable(macro, options) @association_scope_cache = Concurrent::Map.new |