Callbacks can also be registered to only fire on certain lifecycle events:
classUser < ActiveRecord::Base
before_validation :normalize_name, on::create
@@ -1015,7 +1016,7 @@ class User < ActiveRecord::Base
It is considered good practice to declare callback methods as protected or private. If left public, they can be called from outside of the model and violate the principle of object encapsulation.
@@ -1109,14 +1110,16 @@ Additionally, the `after_find` callback is triggered by the following finder met
The `after_initialize` callback is triggered every time a new object of the class is initialized.
NOTE: The `find_all_by_*`, `find_by_*` and `find_by_*!` methods are dynamic finders generated automatically for every attribute. Learn more about them at the [Dynamic finders section](active_record_querying.html#dynamic-finders)