Forum: Ruby on Rails Is it possible to do something before/after a method in a mo

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
ivanvega (Guest)
on 2005-12-02 00:07
(Received via mailing list)
Hi,

I don't know if the subject makes sense, but what I want is to do
certain actions before a record is created, deleted, or updated, and
some other after a successful insert/delete/update.

like maybe:

class School < ActiveRecord::Base
    def new
       do something
       call the default code that handles this function in Rails
       if successful, do more stuff
    end
end

I know I can do it in the controller, that's pretty easy, but the tasks
I want to do involve updating some records on the database, so the code
should belong in the model, I think.

I'm sure this must be possible, but how?

Thanks in advance!

Ivan V.
Simon.Santoro (Guest)
on 2005-12-02 00:24
(Received via mailing list)
Iván Vega R. wrote:
> Hi,
>
> I don't know if the subject makes sense, but what I want is to do
> certain actions before a record is created, deleted, or updated, and
> some other after a successful insert/delete/update.

http://api.rubyonrails.org/classes/ActiveRecord/Ca...
This topic is locked and can not be replied to.