Further improvement to the documentation of has_many method collection.create:

Of course the "associated object" (base model) cannot be nil, or you wouldn't
be calling this method on it. What concerns the user is that the base model
must be present in the DB.
This commit is contained in:
Dave Rothlisberger
2009-12-28 14:33:26 +00:00
parent 44e8f7cf00
commit 3eeb0df402

View File

@@ -772,7 +772,7 @@ module ActiveRecord
# Returns a new object of the collection type that has been instantiated
# with +attributes+, linked to this object through a foreign key, and that has already
# been saved (if it passed the validation). *Note*: This only works if the base model
# already exists, not if it's +nil+ or is a new (unsaved) record!
# already exists in the DB, not if it is a new (unsaved) record!
#
# (*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>.)