diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2014-12-10 19:15:07 -0200 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2014-12-10 19:15:07 -0200 |
commit | 81e940c313b6924915ca77a0f3af66332c9f0b1f (patch) | |
tree | 0648b6f0e34b6cc7e440fff03593e090d7cb8cd0 /activerecord/lib/active_record/reflection.rb | |
parent | efe80bce9765f7fcc1d09338a212f8ea1c4d7a7a (diff) | |
parent | 075c81feec87b1e5bfec27ed585c4ab613c2d174 (diff) | |
download | rails-81e940c313b6924915ca77a0f3af66332c9f0b1f.tar.gz rails-81e940c313b6924915ca77a0f3af66332c9f0b1f.tar.bz2 rails-81e940c313b6924915ca77a0f3af66332c9f0b1f.zip |
Merge pull request #17970 from ulissesalmeida/foreign-type-has-many-has-one
Add foreign_type option for polymorphic has_one and has_many.
Diffstat (limited to 'activerecord/lib/active_record/reflection.rb')
-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 4202bc5665..9849e03036 100644 --- a/activerecord/lib/active_record/reflection.rb +++ b/activerecord/lib/active_record/reflection.rb @@ -277,7 +277,7 @@ module ActiveRecord def initialize(name, scope, options, active_record) super @automatic_inverse_of = nil - @type = options[:as] && "#{options[:as]}_type" + @type = options[:as] && (options[:foreign_type] || "#{options[:as]}_type") @foreign_type = options[:foreign_type] || "#{name}_type" @constructable = calculate_constructable(macro, options) @association_scope_cache = {} |