Reputation: 1312
Having trouble confirming this. Are 'before_save' callbacks executed in the order that they are written?
e.g.
before_save :first, :second
def first
#some code
end
def second
#some code
end
Will first
always be called before second
? Can someone please just give a yes or no answer?
I've read the rails documentation, specifically cancelling callbacks but it doesn't directly answer this question with a yes/no.
Cheers
Upvotes: 4
Views: 1287
Reputation: 1278
Yes the callbacks are executed in the order that they are defined.
after_create :do_this, :and_then_this
Possible Duplicate of Enforce an Order to Rails Callbacks
Upvotes: 4