Comments (5)
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..:-)
from transitions.
@dlepage Oh, and what's your use case for having multiple state machines for one model?
from transitions.
Sure ! :) First of all, most of the time it's better to split a model into simple models... but sometime, it's overkill.
We can imagine a model that you have two(or more) points of view... eg. :
- Human... mental_state, physical_state...
- Order : shipping(processing) state, invoice state (NOTE: I know, an Invoice model can do the trick but adding a model just to manage a state seems overkill (and more left joins is not really better...)).
On 2012-05-18, at 07:16, Timo Rößner wrote:
@dlepage Oh, and what's your use case for having multiple state machines for one model?
Reply to this email directly or view it on GitHub:
#50 (comment)
from transitions.
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.
from transitions.
Please add "this gem is limited to one state machine for each model.
Envoyé de mon iPhone
Le 2012-05-21 à 18:41, "Timo Rößner"
[email protected]
a écrit :
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.
Reply to this email directly or view it on GitHub:
#50 (comment)
from transitions.
Related Issues (20)
- getting "uninitialized constant ActiveRecord::Transitions" with rails 4.1 HOT 2
- can_event methods don't respect guards HOT 1
- Initial state is not set HOT 3
- Problem with Success Callback HOT 5
- Refactor our specs big time
- Introduce rubocop and auto-fix offenses HOT 1
- Fix all remaining rubocop offenses in lib/ and add rubocop to our travis build HOT 1
- Transitions#set_initial_state is forcibly inserting the "state" attribute HOT 6
- new feature: put exception as a param to event_failed HOT 1
- Success callback not fired HOT 1
- Passing parameters to events HOT 1
- Raise error when guard fails HOT 6
- Throw out callbacks... HOT 5
- Introduce Reek for CI HOT 1
- Introduce RDL
- available_state available_events should list states or events in the order they are defined HOT 4
- undefined method `state_machine' for nil:NilClass HOT 4
- Multiple timestamps on state transition HOT 3
- Publish 1.3.0 release HOT 2
- Tapioca DSL compiler interest?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from transitions.