Is it possible to use the ActiveRecord Callbacks
- before_create
- after_create
- before_save
- after_save
- before_destroy
- after_destroy
to display notifications using jquery to the user?
Can someone provide an example??
Thanks
It's not the responsibility of the model to comunicate back to the view. In my opinion this should be handled in the controller, not the model. The controller could look like:
respond_to :json
def create
if @page.save
respond_with {:message => "Aye Okay!"}
else
respond_with {:message => "Oops, something went wrong."}
end
end
The destroy and before create cases could follow the same idea: check manually in the controller and send the message from there.
Not exactly what you asked but I think you should keep them separated.