aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/associations/builder
diff options
context:
space:
mode:
authorUlisses Almeida + Kassio Borges <anizark+kassioborgesm@gmail.com>2014-12-08 17:43:16 -0200
committerUlisses Almeida + Kassio Borges <anizark+kassioborgesm@gmail.com>2014-12-08 18:13:15 -0200
commit075c81feec87b1e5bfec27ed585c4ab613c2d174 (patch)
tree2fad903219acd89c1437d83c9b7737da3b14292e /activerecord/lib/active_record/associations/builder
parent7daeb98c769a3968a2ccf48ff593909bf1a9d7b0 (diff)
downloadrails-075c81feec87b1e5bfec27ed585c4ab613c2d174.tar.gz
rails-075c81feec87b1e5bfec27ed585c4ab613c2d174.tar.bz2
rails-075c81feec87b1e5bfec27ed585c4ab613c2d174.zip
Add foreign_type option for polymorphic has_one and has_many.
To be possible to use a custom column name to save/read the polymorphic associated type in a has_many or has_one polymorphic association, now users can use the option :foreign_type to inform in what column the associated object type will be saved.
Diffstat (limited to 'activerecord/lib/active_record/associations/builder')
-rw-r--r--activerecord/lib/active_record/associations/builder/has_many.rb2
-rw-r--r--activerecord/lib/active_record/associations/builder/has_one.rb2
2 files changed, 2 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/associations/builder/has_many.rb b/activerecord/lib/active_record/associations/builder/has_many.rb
index 4c8c826f76..1b87f92170 100644
--- a/activerecord/lib/active_record/associations/builder/has_many.rb
+++ b/activerecord/lib/active_record/associations/builder/has_many.rb
@@ -5,7 +5,7 @@ module ActiveRecord::Associations::Builder
end
def valid_options
- super + [:primary_key, :dependent, :as, :through, :source, :source_type, :inverse_of, :counter_cache, :join_table]
+ super + [:primary_key, :dependent, :as, :through, :source, :source_type, :inverse_of, :counter_cache, :join_table, :foreign_type]
end
def self.valid_dependent_options
diff --git a/activerecord/lib/active_record/associations/builder/has_one.rb b/activerecord/lib/active_record/associations/builder/has_one.rb
index c194c8ae9a..1387717396 100644
--- a/activerecord/lib/active_record/associations/builder/has_one.rb
+++ b/activerecord/lib/active_record/associations/builder/has_one.rb
@@ -5,7 +5,7 @@ module ActiveRecord::Associations::Builder
end
def valid_options
- valid = super + [:as]
+ valid = super + [:as, :foreign_type]
valid += [:through, :source, :source_type] if options[:through]
valid
end