mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
lifecycle should be two words, life cycle
This commit is contained in:
parent
d9f6e16937
commit
5430f5bd06
10 changed files with 15 additions and 15 deletions
|
@ -93,7 +93,7 @@ module ActiveModel
|
|||
|
||||
# == Active Model Observers
|
||||
#
|
||||
# Observer classes respond to lifecycle callbacks to implement trigger-like
|
||||
# Observer classes respond to life cycle callbacks to implement trigger-like
|
||||
# behavior outside the original class. This is a great way to reduce the
|
||||
# clutter that normally comes when the model class is burdened with
|
||||
# functionality that doesn't pertain to the core responsibility of the
|
||||
|
|
|
@ -5218,7 +5218,7 @@ in effect. Added :readonly finder constraint. Calling an association collectio
|
|||
NOTE: The agreement is considered valid if it's set to the string "1". This makes it easy to relate it to an HTML checkbox.
|
||||
|
||||
|
||||
* Added validation macros to make the stackable just like the lifecycle callbacks. Examples:
|
||||
* Added validation macros to make the stackable just like the life cycle callbacks. Examples:
|
||||
|
||||
class Person < ActiveRecord::Base
|
||||
validate { |record| record.errors.add("name", "too short") unless name.size > 10 }
|
||||
|
|
|
@ -70,7 +70,7 @@ A short rundown of some of the major features:
|
|||
{Learn more}[link:classes/ActiveRecord/Validations.html]
|
||||
|
||||
|
||||
* Callbacks available for the entire lifecycle (instantiation, saving, destroying, validating, etc.)
|
||||
* Callbacks available for the entire life cycle (instantiation, saving, destroying, validating, etc.)
|
||||
|
||||
class Person < ActiveRecord::Base
|
||||
before_destroy :invalidate_payment_plan
|
||||
|
|
|
@ -340,7 +340,7 @@ module ActiveRecord
|
|||
#
|
||||
# === Association callbacks
|
||||
#
|
||||
# Similar to the normal callbacks that hook into the lifecycle of an Active Record object,
|
||||
# Similar to the normal callbacks that hook into the life cycle of an Active Record object,
|
||||
# you can also define callbacks that get triggered when you add an object to or remove an
|
||||
# object from an association collection.
|
||||
#
|
||||
|
|
|
@ -3,7 +3,7 @@ require 'active_support/core_ext/array/wrap'
|
|||
module ActiveRecord
|
||||
# = Active Record Callbacks
|
||||
#
|
||||
# Callbacks are hooks into the lifecycle of an Active Record object that allow you to trigger logic
|
||||
# Callbacks are hooks into the life cycle of an Active Record object that allow you to trigger logic
|
||||
# before or after an alteration of the object state. This can be used to make sure that associated and
|
||||
# dependent objects are deleted when +destroy+ is called (by overwriting +before_destroy+) or to massage attributes
|
||||
# before they're validated (by overwriting +before_validation+). As an example of the callbacks initiated, consider
|
||||
|
@ -26,7 +26,7 @@ module ActiveRecord
|
|||
# <tt>after_rollback</tt>.
|
||||
#
|
||||
# That's a total of ten callbacks, which gives you immense power to react and prepare for each state in the
|
||||
# Active Record lifecycle. The sequence for calling <tt>Base#save</tt> for an existing record is similar,
|
||||
# Active Record life cycle. The sequence for calling <tt>Base#save</tt> for an existing record is similar,
|
||||
# except that each <tt>_on_create</tt> callback is replaced by the corresponding <tt>_on_update</tt> callback.
|
||||
#
|
||||
# Examples:
|
||||
|
|
|
@ -3,7 +3,7 @@ require 'active_support/core_ext/class/attribute'
|
|||
module ActiveRecord
|
||||
# = Active Record Observer
|
||||
#
|
||||
# Observer classes respond to lifecycle callbacks to implement trigger-like
|
||||
# Observer classes respond to life cycle callbacks to implement trigger-like
|
||||
# behavior outside the original class. This is a great way to reduce the
|
||||
# clutter that normally comes when the model class is burdened with
|
||||
# functionality that doesn't pertain to the core responsibility of the
|
||||
|
|
|
@ -30,7 +30,7 @@ that inherits from ActiveResource::Base and providing a <tt>site</tt> class vari
|
|||
end
|
||||
|
||||
Now the Person class is REST enabled and can invoke REST services very similarly to how Active Record invokes
|
||||
lifecycle methods that operate against a persistent store.
|
||||
life cycle methods that operate against a persistent store.
|
||||
|
||||
# Find a person with id = 1
|
||||
ryan = Person.find(1)
|
||||
|
|
|
@ -35,7 +35,7 @@ module ActiveResource
|
|||
# end
|
||||
#
|
||||
# Now the Person class is mapped to RESTful resources located at <tt>http://api.people.com:3000/people/</tt>, and
|
||||
# you can now use Active Resource's lifecycle methods to manipulate resources. In the case where you already have
|
||||
# you can now use Active Resource's life cycle methods to manipulate resources. In the case where you already have
|
||||
# an existing model with the same name as the desired RESTful resource you can set the +element_name+ value.
|
||||
#
|
||||
# class PersonResource < ActiveResource::Base
|
||||
|
@ -51,7 +51,7 @@ module ActiveResource
|
|||
# end
|
||||
#
|
||||
#
|
||||
# == Lifecycle methods
|
||||
# == Life cycle methods
|
||||
#
|
||||
# Active Resource exposes methods for creating, finding, updating, and deleting resources
|
||||
# from REST web services.
|
||||
|
@ -70,12 +70,12 @@ module ActiveResource
|
|||
#
|
||||
# ryan.destroy # => true
|
||||
#
|
||||
# As you can see, these are very similar to Active Record's lifecycle methods for database records.
|
||||
# As you can see, these are very similar to Active Record's life cycle methods for database records.
|
||||
# You can read more about each of these methods in their respective documentation.
|
||||
#
|
||||
# === Custom REST methods
|
||||
#
|
||||
# Since simple CRUD/lifecycle methods can't accomplish every task, Active Resource also supports
|
||||
# Since simple CRUD/life cycle methods can't accomplish every task, Active Resource also supports
|
||||
# defining your own custom REST methods. To invoke them, Active Resource provides the <tt>get</tt>,
|
||||
# <tt>post</tt>, <tt>put</tt> and <tt>\delete</tt> methods where you can specify a custom REST method
|
||||
# name to invoke.
|
||||
|
|
|
@ -5,7 +5,7 @@ require 'active_support/core_ext/kernel/reporting'
|
|||
require 'active_support/core_ext/kernel/singleton_class'
|
||||
|
||||
module ActiveSupport
|
||||
# Callbacks are hooks into the lifecycle of an object that allow you to trigger logic
|
||||
# Callbacks are hooks into the life cycle of an object that allow you to trigger logic
|
||||
# before or after an alteration of the object state.
|
||||
#
|
||||
# Mixing in this module allows you to define callbacks in your class.
|
||||
|
|
|
@ -1760,9 +1760,9 @@ If you want to assign an object to a +has_and_belongs_to_many+ association witho
|
|||
|
||||
h4. Association Callbacks
|
||||
|
||||
Normal callbacks hook into the lifecycle of Active Record objects, allowing you to work with those objects at various points. For example, you can use a +:before_save+ callback to cause something to happen just before an object is saved.
|
||||
Normal callbacks hook into the life cycle of Active Record objects, allowing you to work with those objects at various points. For example, you can use a +:before_save+ callback to cause something to happen just before an object is saved.
|
||||
|
||||
Association callbacks are similar to normal callbacks, but they are triggered by events in the lifecycle of a collection. There are four available association callbacks:
|
||||
Association callbacks are similar to normal callbacks, but they are triggered by events in the life cycle of a collection. There are four available association callbacks:
|
||||
|
||||
* +before_add+
|
||||
* +after_add+
|
||||
|
|
Loading…
Reference in a new issue