aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/associations.rb
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2014-12-10 19:15:07 -0200
committerRafael Mendonça França <rafaelmfranca@gmail.com>2014-12-10 19:15:07 -0200
commit81e940c313b6924915ca77a0f3af66332c9f0b1f (patch)
tree0648b6f0e34b6cc7e440fff03593e090d7cb8cd0 /activerecord/lib/active_record/associations.rb
parentefe80bce9765f7fcc1d09338a212f8ea1c4d7a7a (diff)
parent075c81feec87b1e5bfec27ed585c4ab613c2d174 (diff)
downloadrails-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/associations.rb')
-rw-r--r--activerecord/lib/active_record/associations.rb12
1 files changed, 12 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/associations.rb b/activerecord/lib/active_record/associations.rb
index eb21712f96..cd5fdd5964 100644
--- a/activerecord/lib/active_record/associations.rb
+++ b/activerecord/lib/active_record/associations.rb
@@ -1176,6 +1176,12 @@ module ActiveRecord
# Specify the foreign key used for the association. By default this is guessed to be the name
# of this class in lower-case and "_id" suffixed. So a Person class that makes a +has_many+
# association will use "person_id" as the default <tt>:foreign_key</tt>.
+ # [:foreign_type]
+ # Specify the column used to store the associated object's type, if this is a polymorphic
+ # association. By default this is guessed to be the name of the polymorphic association
+ # specified on "as" option with a "_type" suffix. So a class that defines a
+ # <tt>has_many :tags, as: :taggable</tt> association will use "taggable_type" as the
+ # default <tt>:foreign_type</tt>.
# [:primary_key]
# Specify the name of the column to use as the primary key for the association. By default this is +id+.
# [:dependent]
@@ -1323,6 +1329,12 @@ module ActiveRecord
# Specify the foreign key used for the association. By default this is guessed to be the name
# of this class in lower-case and "_id" suffixed. So a Person class that makes a +has_one+ association
# will use "person_id" as the default <tt>:foreign_key</tt>.
+ # [:foreign_type]
+ # Specify the column used to store the associated object's type, if this is a polymorphic
+ # association. By default this is guessed to be the name of the polymorphic association
+ # specified on "as" option with a "_type" suffix. So a class that defines a
+ # <tt>has_one :tag, as: :taggable</tt> association will use "taggable_type" as the
+ # default <tt>:foreign_type</tt>.
# [:primary_key]
# Specify the method that returns the primary key used for the association. By default this is +id+.
# [:as]