From bc568a1a19f91c2f050eae8f489e5d3345b5c9ba Mon Sep 17 00:00:00 2001 From: Xavier Noria Date: Mon, 5 May 2008 22:57:15 +0200 Subject: revised conventions in associations.rb --- activerecord/lib/active_record/associations.rb | 56 +++++++++++++------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/activerecord/lib/active_record/associations.rb b/activerecord/lib/active_record/associations.rb index 7d27b0607a..5251a7b0f5 100755 --- a/activerecord/lib/active_record/associations.rb +++ b/activerecord/lib/active_record/associations.rb @@ -640,45 +640,45 @@ module ActiveRecord # The declaration can also include an options hash to specialize the behavior of the association. # # Options are: - # * :class_name - specify the class name of the association. Use it only if that name can't be inferred - # from the association name. So has_many :products will by default be linked to the +Product+ class, but - # if the real class name is +SpecialProduct+, you'll have to specify it with this option. - # * :conditions - specify the conditions that the associated objects must meet in order to be included as a +WHERE+ + # * :class_name - Specify the class name of the association. Use it only if that name can't be inferred + # from the association name. So has_many :products will by default be linked to the Product class, but + # if the real class name is SpecialProduct, you'll have to specify it with this option. + # * :conditions - Specify the conditions that the associated objects must meet in order to be included as a +WHERE+ # SQL fragment, such as price > 5 AND name LIKE 'B%'. Record creations from the association are scoped if a hash # is used. has_many :posts, :conditions => {:published => true} will create published posts with @blog.posts.create # or @blog.posts.build. - # * :order - specify the order in which the associated objects are returned as an ORDER BY SQL fragment, - # such as last_name, first_name DESC - # * :foreign_key - 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+ + # * :order - Specify the order in which the associated objects are returned as an ORDER BY SQL fragment, + # such as last_name, first_name DESC. + # * :foreign_key - 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 +foreign_key+. - # * :dependent - if set to :destroy all the associated objects are destroyed - # alongside this object by calling their destroy method. If set to :delete_all all associated - # objects are deleted *without* calling their destroy method. If set to :nullify all associated - # objects' foreign keys are set to +NULL+ *without* calling their save callbacks. *Warning:* This option is ignored when also using - # the through option. - # * :finder_sql - specify a complete SQL statement to fetch the association. This is a good way to go for complex + # * :dependent - If set to :destroy all the associated objects are destroyed + # alongside this object by calling their +destroy+ method. If set to :delete_all all associated + # objects are deleted *without* calling their +destroy+ method. If set to :nullify all associated + # objects' foreign keys are set to +NULL+ *without* calling their +save+ callbacks. *Warning:* This option is ignored when also using + # the :through option. + # * :finder_sql - Specify a complete SQL statement to fetch the association. This is a good way to go for complex # associations that depend on multiple tables. Note: When this option is used, +find_in_collection+ is _not_ added. - # * :counter_sql - specify a complete SQL statement to fetch the size of the association. If :finder_sql is + # * :counter_sql - Specify a complete SQL statement to fetch the size of the association. If :finder_sql is # specified but not :counter_sql, :counter_sql will be generated by replacing SELECT ... FROM with SELECT COUNT(*) FROM. - # * :extend - specify a named module for extending the proxy. See "Association extensions". - # * :include - specify second-order associations that should be eager loaded when the collection is loaded. - # * :group: An attribute name by which the result should be grouped. Uses the GROUP BY SQL-clause. - # * :limit: An integer determining the limit on the number of rows that should be returned. - # * :offset: An integer determining the offset from where the rows should be fetched. So at 5, it would skip the first 4 rows. - # * :select: By default, this is * as in SELECT * FROM, but can be changed if you, for example, want to do a join + # * :extend - Specify a named module for extending the proxy. See "Association extensions". + # * :include - Specify second-order associations that should be eager loaded when the collection is loaded. + # * :group - An attribute name by which the result should be grouped. Uses the GROUP BY SQL-clause. + # * :limit - An integer determining the limit on the number of rows that should be returned. + # * :offset - An integer determining the offset from where the rows should be fetched. So at 5, it would skip the first 4 rows. + # * :select - By default, this is * as in SELECT * FROM, but can be changed if you, for example, want to do a join # but not include the joined columns. - # * :as: Specifies a polymorphic interface (See #belongs_to). - # * :through: Specifies a Join Model through which to perform the query. Options for :class_name and :foreign_key + # * :as - Specifies a polymorphic interface (See belongs_to). + # * :through - Specifies a Join Model through which to perform the query. Options for :class_name and :foreign_key # are ignored, as the association uses the source reflection. You can only use a :through query through a belongs_to # or has_many association on the join model. - # * :source: Specifies the source association name used by has_many :through queries. Only use it if the name cannot be + # * :source - Specifies the source association name used by has_many :through queries. Only use it if the name cannot be # inferred from the association. has_many :subscribers, :through => :subscriptions will look for either :subscribers or - # :subscriber on +Subscription+, unless a :source is given. - # * :source_type: Specifies type of the source association used by has_many :through queries where the source + # :subscriber on Subscription, unless a :source is given. + # * :source_type - Specifies type of the source association used by has_many :through queries where the source # association is a polymorphic +belongs_to+. - # * :uniq - if set to +true+, duplicates will be omitted from the collection. Useful in conjunction with :through. - # * :readonly - if set to +true+, all the associated objects are readonly through the association. + # * :uniq - If true, duplicates will be omitted from the collection. Useful in conjunction with :through. + # * :readonly - If true, all the associated objects are readonly through the association. # # Option examples: # has_many :comments, :order => "posted_on" -- cgit v1.2.3