aboutsummaryrefslogtreecommitdiffstats
path: root/railties
diff options
context:
space:
mode:
authorFlorian Walch <florian.walch@mineum.at>2011-11-05 13:34:01 +0100
committerFlorian Walch <florian.walch@mineum.at>2011-11-05 13:34:01 +0100
commitbcd25e7576094a98dbc9f4b1ba2fb3451d13bf40 (patch)
tree75bf2cffd0688c5447d9871b7b5ec1f7124ea881 /railties
parent36a5f48f9323c4a770c290a9a16ae58388e7925f (diff)
downloadrails-bcd25e7576094a98dbc9f4b1ba2fb3451d13bf40.tar.gz
rails-bcd25e7576094a98dbc9f4b1ba2fb3451d13bf40.tar.bz2
rails-bcd25e7576094a98dbc9f4b1ba2fb3451d13bf40.zip
Fixed after_initialize/after_find guide
Defining after_initialize and after_find as ordinary methods like documented in the guide doesn't work with Rails 3.1.1; now macro-style is used here, too.
Diffstat (limited to 'railties')
-rw-r--r--railties/guides/source/active_record_validations_callbacks.textile6
1 files changed, 3 insertions, 3 deletions
diff --git a/railties/guides/source/active_record_validations_callbacks.textile b/railties/guides/source/active_record_validations_callbacks.textile
index 4c1f66aedf..a27c292a4c 100644
--- a/railties/guides/source/active_record_validations_callbacks.textile
+++ b/railties/guides/source/active_record_validations_callbacks.textile
@@ -978,15 +978,15 @@ The +after_initialize+ callback will be called whenever an Active Record object
The +after_find+ callback will be called whenever Active Record loads a record from the database. +after_find+ is called before +after_initialize+ if both are defined.
-The +after_initialize+ and +after_find+ callbacks are a bit different from the others. They have no +before_*+ counterparts, and they are registered simply by defining them as regular methods with predefined names. If you try to register +after_initialize+ or +after_find+ using macro-style class methods, they will just be ignored. This behavior is due to performance reasons, since +after_initialize+ and +after_find+ will both be called for each record found in the database, which would otherwise significantly slow down the queries.
+The +after_initialize+ and +after_find+ callbacks have no +before_*+ counterparts, but they can be registered just like the other Active Record callbacks.
<ruby>
class User < ActiveRecord::Base
- def after_initialize
+ after_initialize do |user|
puts "You have initialized an object!"
end
- def after_find
+ after_find do |user|
puts "You have found an object!"
end
end