提交 3a707e21 编写于 作者: L Logan Hasson

[ci skip] Move association class method notes

Make explanation of association class methods clearer by moving notes to beginning of each example section.
上级 e9bfa28b
......@@ -1034,6 +1034,9 @@ module ClassMethods
# Specifies a one-to-many association. The following methods for retrieval and query of
# collections of associated objects will be added:
#
# +collection+ is a placeholder for the symbol passed as the first argument, so
# <tt>has_many :clients</tt> would add among others <tt>clients.empty?</tt>.
#
# [collection(force_reload = false)]
# Returns an array of all the associated objects.
# An empty array is returned if none are found.
......@@ -1092,9 +1095,6 @@ module ClassMethods
# Does the same as <tt>collection.create</tt>, but raises <tt>ActiveRecord::RecordInvalid</tt>
# if the record is invalid.
#
# (*Note*: +collection+ is replaced with the symbol passed as the first argument, so
# <tt>has_many :clients</tt> would add among others <tt>clients.empty?</tt>.)
#
# === Example
#
# A <tt>Firm</tt> class declares <tt>has_many :clients</tt>, which will add:
......@@ -1209,6 +1209,9 @@ def has_many(name, scope = nil, options = {}, &extension)
#
# The following methods for retrieval and query of a single associated object will be added:
#
# +association+ is a placeholder for the symbol passed as the first argument, so
# <tt>has_one :manager</tt> would add among others <tt>manager.nil?</tt>.
#
# [association(force_reload = false)]
# Returns the associated object. +nil+ is returned if none is found.
# [association=(associate)]
......@@ -1226,9 +1229,6 @@ def has_many(name, scope = nil, options = {}, &extension)
# Does the same as <tt>create_association</tt>, but raises <tt>ActiveRecord::RecordInvalid</tt>
# if the record is invalid.
#
# (+association+ is replaced with the symbol passed as the first argument, so
# <tt>has_one :manager</tt> would add among others <tt>manager.nil?</tt>.)
#
# === Example
#
# An Account class declares <tt>has_one :beneficiary</tt>, which will add:
......@@ -1314,6 +1314,9 @@ def has_one(name, scope = nil, options = {})
# Methods will be added for retrieval and query for a single associated object, for which
# this object holds an id:
#
# +association+ is a placeholder for the symbol passed as the first argument, so
# <tt>belongs_to :author</tt> would add among others <tt>author.nil?</tt>.
#
# [association(force_reload = false)]
# Returns the associated object. +nil+ is returned if none is found.
# [association=(associate)]
......@@ -1329,9 +1332,6 @@ def has_one(name, scope = nil, options = {})
# Does the same as <tt>create_association</tt>, but raises <tt>ActiveRecord::RecordInvalid</tt>
# if the record is invalid.
#
# (+association+ is replaced with the symbol passed as the first argument, so
# <tt>belongs_to :author</tt> would add among others <tt>author.nil?</tt>.)
#
# === Example
#
# A Post class declares <tt>belongs_to :author</tt>, which will add:
......@@ -1451,6 +1451,9 @@ def belongs_to(name, scope = nil, options = {})
#
# Adds the following methods for retrieval and query:
#
# +collection+ is a placeholder for the symbol passed as the first argument, so
# <tt>has_and_belongs_to_many :categories</tt> would add among others <tt>categories.empty?</tt>.
#
# [collection(force_reload = false)]
# Returns an array of all the associated objects.
# An empty array is returned if none are found.
......@@ -1492,9 +1495,6 @@ def belongs_to(name, scope = nil, options = {})
# with +attributes+, linked to this object through the join table, and that has already been
# saved (if it passed the validation).
#
# (+collection+ is replaced with the symbol passed as the first argument, so
# <tt>has_and_belongs_to_many :categories</tt> would add among others <tt>categories.empty?</tt>.)
#
# === Example
#
# A Developer class declares <tt>has_and_belongs_to_many :projects</tt>, which will add:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册