ruby on rails - How do I execute transitions in AASM from controller? -


Is it possible to safely execute the infection by using its name in ASAM?

Now what am I doing in ASAM:

  if order.aasm.events.include? What can I do in  state_machine  

  

  order.state_event = params [: event] order.save   

Can you do your aasm do block? I have not used before state_machine , but it is not how a typical uses aasm you do not need to send the transition anytime; Rather, you only call the event and you automatically transit states based on the incident / transition rules you have made.

Here's a short example.

  aasm do state: draft state: review state: approved state: rejected event: submit change: from = & gt; : Draft ,: from = & gt; : Review transition: from = & gt; : Review, and = & gt; : Approved end event: reject changes: form = & gt; : Review, and = & gt; : In the example given above, if the item is in the draft state and you call  object.submit  then this  drafts Will have a transition from  to review and if you are in the review state then there will be a change in the  object.submit  from  review accepted . 

Also note that instead of calling the event, and then by saving, you can call a ! can be added to the event name and after the save, the transition will be done automatically.

Therefore you can only call

  object.submit object.save  

  object.submit!  

Comments

Popular posts from this blog

winforms - C# Form - Property Change -

c# - NewtonSoft JArray - how to select multiple elements with LINQ -

javascript - amcharts makechart not working -