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

Initial transition not created/callbacks not fired unless state_machine is touched #547

Open
mikebaldry opened this issue Dec 6, 2024 · 0 comments

Comments

@mikebaldry
Copy link

The documentation suggests implementing like:

def state_machine
  @state_machine ||= OrderStateMachine.new(self, transition_class: OrderTransition,
                                                 association_name: :transitions,
                                                 initial_transition: true)
end

the initial transition is created and the callbacks then fired from this initializer, so if the state_machine isn't called after create of a model, this doesn't fire.

I'm not exactly sure of the scenarios state_machine isn't touched, if something happens internally with Statesman but not always or if it mostly happens that our code touches it in most cases, but we've had sporadic issues that has led me to add

after_create { state_machine }

to the models using Statesman, which appears to fix.

Should we need to do this, if so, could it be added to the documentation, if not, any ideas where we're going wrong?

Many thanks!

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

1 participant