Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question] Is there an easy way to rollback a transition? #459

Open
leandrofinger opened this issue Mar 16, 2022 · 1 comment
Open

[Question] Is there an easy way to rollback a transition? #459

leandrofinger opened this issue Mar 16, 2022 · 1 comment

Comments

@leandrofinger
Copy link

Hi guys!

After transitioning and depending on the record I should run an integration call and depending on this response I need rollback the last transition. Is there an easy way to do that, or should I allow the transition backward and transition it again?

@dmitry
Copy link
Contributor

dmitry commented Sep 2, 2023

At least what I know:

  • Destroy the last transition via state_machine.last_transition.destroy; please make sure you have after_destroy :update_most_recent, if: :most_recent? code, which updates the previous most recent transition's row value most_recent to true.
  • Add a backwards transition to the state machine, which is preferred if you would like to make the logic on rollback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants