1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

More documentation about methods taking blocks.

This commit is contained in:
Ryan Bigg 2009-07-16 07:52:49 +10:00
parent bb8fb2d143
commit 00d899e11f

View file

@ -276,11 +276,19 @@ module ActiveRecord
private :create_with_callbacks private :create_with_callbacks
# Is called _before_ <tt>Base.save</tt> on existing objects that have a record. # Is called _before_ <tt>Base.save</tt> on existing objects that have a record.
#
# class Contact < ActiveRecord::Base
# before_update { |record| logger.info( "Contact #{record.id} is about to be updated." ) }
# end
def before_update() end def before_update() end
# Is called _after_ <tt>Base.save</tt> on existing objects that have a record. # Is called _after_ <tt>Base.save</tt> on existing objects that have a record.
# Note that this callback is still wrapped in the transaction around +save+. For example, if you # Note that this callback is still wrapped in the transaction around +save+. For example, if you
# invoke an external indexer at this point it won't see the changes in the database. # invoke an external indexer at this point it won't see the changes in the database.
#
# class Contact < ActiveRecord::Base
# after_update { |record| logger.info( "Contact #{record.id} was updated." ) }
# end
def after_update() end def after_update() end
def update_with_callbacks(*args) #:nodoc: def update_with_callbacks(*args) #:nodoc:
@ -330,6 +338,10 @@ module ActiveRecord
# #
# Note: If you need to _destroy_ or _nullify_ associated records first, # Note: If you need to _destroy_ or _nullify_ associated records first,
# use the <tt>:dependent</tt> option on your associations. # use the <tt>:dependent</tt> option on your associations.
#
# class Contact < ActiveRecord::Base
# after_destroy { |record| logger.info( "Contact #{record.id} is about to be destroyed." ) }
# end
def before_destroy() end def before_destroy() end
# Is called _after_ <tt>Base.destroy</tt> (and all the attributes have been frozen). # Is called _after_ <tt>Base.destroy</tt> (and all the attributes have been frozen).