From 539fafc30cd9db96c5c04f7bdaf26e612be5051d Mon Sep 17 00:00:00 2001 From: CassioMarques Date: Sat, 13 Dec 2008 22:09:39 -0200 Subject: Added some text about the possibility of observers' registration also at the config/environment files (AR Validations and Callbacks Guide) --- railties/doc/guides/html/activerecord_validations_callbacks.html | 4 +++- railties/doc/guides/source/activerecord_validations_callbacks.txt | 6 +++++- 2 files changed, 8 insertions(+), 2 deletions(-) (limited to 'railties/doc/guides') diff --git a/railties/doc/guides/html/activerecord_validations_callbacks.html b/railties/doc/guides/html/activerecord_validations_callbacks.html index 9ce19ee614..039e3d1891 100644 --- a/railties/doc/guides/html/activerecord_validations_callbacks.html +++ b/railties/doc/guides/html/activerecord_validations_callbacks.html @@ -1195,7 +1195,7 @@ http://www.gnu.org/software/src-highlite --> end

12.1. Registering observers

-

If you payed attention, you may be wondering where Active Record Observers are referenced in our applications, so they get instantiate and begin to interact with our models. For observers to work we need to register then in our application's config/environment.rb file. In this file there is a commented out line where we can define the observers that our application should load at start-up.

+

If you payed attention, you may be wondering where Active Record Observers are referenced in our applications, so they get instantiate and begin to interact with our models. For observers to work we need to register them somewhere. The usual place to do that is in our application's config/environment.rb file. In this file there is a commented out line where we can define the observers that our application should load at start-up.

# Activate observers that should always be running
 config.active_record.observers = :registration_observer, :auditor
 
+

You can uncomment the line with config.active_record.observers and change the symbols for the name of the observers that should be registered.

+

It's also possible to register callbacks in any of the files living at config/environments/, if you want an observer to work only in a specific environment. There is not a config.active_record.observers line at any of those files, but you can simply add it.

12.2. Where to put the observers' source files

By convention, you should always save your observers' source files inside app/models.

diff --git a/railties/doc/guides/source/activerecord_validations_callbacks.txt b/railties/doc/guides/source/activerecord_validations_callbacks.txt index 9994d7adf3..e0bb534d0b 100644 --- a/railties/doc/guides/source/activerecord_validations_callbacks.txt +++ b/railties/doc/guides/source/activerecord_validations_callbacks.txt @@ -688,7 +688,7 @@ end === Registering observers -If you payed attention, you may be wondering where Active Record Observers are referenced in our applications, so they get instantiate and begin to interact with our models. For observers to work we need to register then in our application's *config/environment.rb* file. In this file there is a commented out line where we can define the observers that our application should load at start-up. +If you payed attention, you may be wondering where Active Record Observers are referenced in our applications, so they get instantiate and begin to interact with our models. For observers to work we need to register them somewhere. The usual place to do that is in our application's *config/environment.rb* file. In this file there is a commented out line where we can define the observers that our application should load at start-up. [source, ruby] ------------------------------------------------------------------ @@ -696,6 +696,10 @@ If you payed attention, you may be wondering where Active Record Observers are r config.active_record.observers = :registration_observer, :auditor ------------------------------------------------------------------ +You can uncomment the line with +config.active_record.observers+ and change the symbols for the name of the observers that should be registered. + +It's also possible to register callbacks in any of the files living at *config/environments/*, if you want an observer to work only in a specific environment. There is not a +config.active_record.observers+ line at any of those files, but you can simply add it. + === Where to put the observers' source files By convention, you should always save your observers' source files inside *app/models*. -- cgit v1.2.3