You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
aasmcolumn: :status,whiny_transitions: falsedostate:requested,initial: truestate:approvedevent:approve,after: :after_approvedotransitionsfrom: :requested,to: :approvedendenddefafter_approveraise"This is a test"end
Given the above I want to be able to call obj.approve! and still have it return true or false so I can handle the exceptions in the model, add errors to the object and handle it in the controller.
I have tried returning false, error handlers etc but it seems there is no way to stop the event from the after callback without raising, nor is there any way to catch the exception handle it and return false (that I can find).
As a workaround I've had to create a new method which wraps the call to approve!
In Rails in after callbacks you need to raise ActiveRecord::RecordInvalid, self and the callback chain will be aborted but the exception is not passed up the stack. To do the same in before_ callbacks you can throw(:abort)
Given the above I want to be able to call
obj.approve!
and still have it returntrue
orfalse
so I can handle the exceptions in the model, add errors to the object and handle it in the controller.I have tried returning false, error handlers etc but it seems there is no way to stop the event from the after callback without raising, nor is there any way to catch the exception handle it and return false (that I can find).
As a workaround I've had to create a new method which wraps the call to
approve!
Is there no way to achieve this in aasm without adding these wrappers?
The text was updated successfully, but these errors were encountered: