hari bhat wrote:> I want to know more about callbacks in
> rails,i am not getting in application when have to use?.
>
> I know it acts like triggers .Please explain me with examples.
I assume you are referring to the ActiveRecord callbacks like
before_save, after_save, before_validation, etc. Understanding them is
pretty simple. They are basically "hooks" into the ActiveRecord call
stack. These "hooks" are opportunities to inject your own code to be
run
by the Rails framework in a consistent and reliable way.
There are many scenarios that you will run across where these hooks are
useful. For example you may want to format, or otherwise modify, user
input before performing validation. Such code can be implemented in a
before_validation method. All that''s required is to implement the
method
in the associated model class. This method will be automatically called,
at the appropriate time, by the Rails framework. This provides a clean,
consistent API for performing such tasks.
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.