Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Multiple state_machines... #50

Closed
dlepage opened this Issue · 5 comments

2 participants

Daniel Lepage Timo Rößner
Daniel Lepage
dlepage commented

Is it possible to have more than one state_machine in a model.

How to setup (state column name, fire évents from this second state_machine ?)

Many thanks !

Timo Rößner
Owner

Well, in theory it should be possible, however I found out that this doesn't work right now unfortunately.
If I find the time, I'll fix that - of course pull requests are welcome..:-)
To be honest this isn't very high on my priority list, because whenever I had the need for two state machines, I basically wanted two different models. However I don't deny that there might be use cases where multiple state machines make sense, I just haven't encountered one.
As far as I can see even naming a state machine with

state_machine :foo do

breaks the functionality. But then again, naming a state machine only makes sense if we have more than one (otherwise it's just default), so this is all more or less the same issue.

I am thinking of something like this (This won't work right now):

state_machine do # name will be `default`
  ...
end

state_machine :foo
  ...
end

where you can switch like that

my_model.switch_state_machine :foo

If you need that badly, you'll have to come up with a pull request I'm afraid..:-)

Timo Rößner
Owner

@dlepage Oh, and what's your use case for having multiple state machines for one model?

Daniel Lepage
dlepage commented
Timo Rößner
Owner

I see your reasoning. However, I am not convinced - "Human being" would be a "human" object composed of "body" and "spirit" for me...:-)
I am closing this issue.

Timo Rößner troessner closed this
Daniel Lepage
dlepage commented
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.