Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

after_create with multiple methods?

I am trying to call two methods on an after create, but putting them into an array doesn't work... i can't find anything in the rails docs or google... anyone with experience?

after_create [:do_this, :do_that] 

does not work

like image 335
Joel Grannas Avatar asked Jan 18 '13 02:01

Joel Grannas


1 Answers

No need to surround the methods in array. Simply use:

after_create :do_this, :and_then_this

Bonus Information: If a before_* callback returns false, all the later callbacks and the associated action are cancelled. If an after_* callback returns false, all the later callbacks are cancelled. Callbacks are generally run in the order they are defined, with the exception of callbacks defined as methods on the model, which are called last.

like image 186
atmaish Avatar answered Sep 21 '22 20:09

atmaish