Browse files

Add documentation for the :foreign_type option on belongs_to

  • Loading branch information...
1 parent 16065b4 commit d18a27031f8794b0134645eb0d62ec16653ac537 @jonleighton jonleighton committed with tenderlove Jan 1, 2011
Showing with 5 additions and 0 deletions.
  1. +5 −0 activerecord/lib/active_record/associations.rb
View
5 activerecord/lib/active_record/associations.rb
@@ -1177,6 +1177,11 @@ def has_one(association_id, options = {})
# association will use "person_id" as the default <tt>:foreign_key</tt>. Similarly,
# <tt>belongs_to :favorite_person, :class_name => "Person"</tt> will use a foreign key
# of "favorite_person_id".
+ # [: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 association with a "_type"
+ # suffix. So a class that defines a <tt>belongs_to :taggable, :polymorphic => true</tt>
+ # association will use "taggable_type" as the default <tt>:foreign_type</tt>.
# [:primary_key]
# Specify the method that returns the primary key of associated object used for the association.
# By default this is id.

0 comments on commit d18a270

Please sign in to comment.