Adanowsky Galvan Gonzalez Thu Mar 08 10:09:52 -0500 2012

Subject: after_* callbacks

Hello Everybody,

I would like to know if is it possible to limit some after/before callbacks only in certain methods like in RoR

:only => :method
:on =>:method

i'm asking this because i want to use a callback only on a create method...

my class is something like this..

class Product extends ActiveRecord\Model {
static $after_save = array('decrease_credit');
static $has_many = array(
array('images')
);
static $belongs_to = array(
array('shop')
);
.
.
.
}

and what i want to do is change the product->quantity property but when i save it the credit decreases because of the callback..

Are there any other way to achieve that?


Adanowsky Galvan Gonzalez Thu Mar 08 12:18:13 -0500 2012

ok fellas i have work it out using alternative methods such as the following described in the usage page:

after_create: called after a NEW model has been inserted into the database
after_update: called after an existing model has been saved

thank you very much!..
I'm testing them!

(1-1/1)