mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
format fix for locking [Michael Koziarski]
Add documentation for :dependent on associations. [robby@planetargon.com] Closes #4151 git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3822 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
parent
43398433e9
commit
57565b3506
3 changed files with 10 additions and 5 deletions
|
@ -1,5 +1,7 @@
|
||||||
*SVN*
|
*SVN*
|
||||||
|
|
||||||
|
* Documentation fixes for :dependent [robby@planetargon.com]
|
||||||
|
|
||||||
* Allow set_fixture_class to take Classes instead of strings for a class in a module. Raise FixtureClassNotFound if a fixture can't load. [Rick Olson]
|
* Allow set_fixture_class to take Classes instead of strings for a class in a module. Raise FixtureClassNotFound if a fixture can't load. [Rick Olson]
|
||||||
|
|
||||||
* Fix quoting of inheritance column for STI eager loading #4098 [Jonathan Viney <jonathan@bluewire.net.nz>]
|
* Fix quoting of inheritance column for STI eager loading #4098 [Jonathan Viney <jonathan@bluewire.net.nz>]
|
||||||
|
|
|
@ -310,10 +310,11 @@ module ActiveRecord
|
||||||
# * <tt>:foreign_key</tt> - specify the foreign key used for the association. By default this is guessed to be the name
|
# * <tt>:foreign_key</tt> - 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"
|
# 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.
|
# as the default foreign_key.
|
||||||
# * <tt>:dependent</tt> - if set to :destroy (or true) all the associated objects are destroyed
|
# * <tt>:dependent</tt> - 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
|
# 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 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.
|
# objects' foreign keys are set to NULL *without* calling their save callbacks.
|
||||||
|
# NOTE: :dependent => true is deprecated and has been replaced with :dependent => :destroy.
|
||||||
# May not be set if :exclusively_dependent is also set.
|
# May not be set if :exclusively_dependent is also set.
|
||||||
# * <tt>:exclusively_dependent</tt> - Deprecated; equivalent to :dependent => :delete_all. If set to true all
|
# * <tt>:exclusively_dependent</tt> - Deprecated; equivalent to :dependent => :delete_all. If set to true all
|
||||||
# the associated object are deleted in one SQL statement without having their
|
# the associated object are deleted in one SQL statement without having their
|
||||||
|
@ -336,7 +337,8 @@ module ActiveRecord
|
||||||
# has_many :comments, :order => "posted_on"
|
# has_many :comments, :order => "posted_on"
|
||||||
# has_many :comments, :include => :author
|
# has_many :comments, :include => :author
|
||||||
# has_many :people, :class_name => "Person", :conditions => "deleted = 0", :order => "name"
|
# has_many :people, :class_name => "Person", :conditions => "deleted = 0", :order => "name"
|
||||||
# has_many :tracks, :order => "position", :dependent => true
|
# has_many :tracks, :order => "position", :dependent => :destroy
|
||||||
|
# has_many :comments, :dependent => :nullify
|
||||||
# has_many :subscribers, :class_name => "Person", :finder_sql =>
|
# has_many :subscribers, :class_name => "Person", :finder_sql =>
|
||||||
# 'SELECT DISTINCT people.* ' +
|
# 'SELECT DISTINCT people.* ' +
|
||||||
# 'FROM people p, post_subscriptions ps ' +
|
# 'FROM people p, post_subscriptions ps ' +
|
||||||
|
@ -396,7 +398,8 @@ module ActiveRecord
|
||||||
# * <tt>:include</tt> - specify second-order associations that should be eager loaded when this object is loaded.
|
# * <tt>:include</tt> - specify second-order associations that should be eager loaded when this object is loaded.
|
||||||
#
|
#
|
||||||
# Option examples:
|
# Option examples:
|
||||||
# has_one :credit_card, :dependent => true
|
# has_one :credit_card, :dependent => :destroy # destroys the associated credit card
|
||||||
|
# has_one :credit_card, :dependent => :nullify # updates the associated records foriegn key value to null rather than destroying it
|
||||||
# has_one :last_comment, :class_name => "Comment", :order => "posted_on"
|
# has_one :last_comment, :class_name => "Comment", :order => "posted_on"
|
||||||
# has_one :project_manager, :class_name => "Person", :conditions => "role = 'project_manager'"
|
# has_one :project_manager, :class_name => "Person", :conditions => "role = 'project_manager'"
|
||||||
def has_one(association_id, options = {})
|
def has_one(association_id, options = {})
|
||||||
|
@ -813,7 +816,7 @@ module ActiveRecord
|
||||||
when nil, false
|
when nil, false
|
||||||
# pass
|
# pass
|
||||||
else
|
else
|
||||||
raise ArgumentError, 'The :dependent option expects either true, :destroy, :delete_all, or :nullify'
|
raise ArgumentError, 'The :dependent option expects either :destroy, :delete_all, or :nullify'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -61,7 +61,7 @@ module ActiveRecord
|
||||||
|
|
||||||
class << self
|
class << self
|
||||||
def set_locking_column( value=nil, &block )
|
def set_locking_column( value=nil, &block )
|
||||||
define_attr_method :locking_column, value, &block
|
define_attr_method :locking_column, value, &block
|
||||||
end
|
end
|
||||||
|
|
||||||
def locking_column
|
def locking_column
|
||||||
|
|
Loading…
Reference in a new issue