Domanda

I need a state machine for a message private system and order status system.

you can see these two gems:

https://github.com/pluginaweek/state_machine

https://github.com/rubyist/aasm

Edited..

I'm using mongoid with mongodb database

What gem is most appropriate for this features?

È stato utile?

Soluzione

Update:

Check out the recent RailsCast: A Tour of State Machines

Previous Answer:

Both gems are working great, are compatible with Mongoid, and are actively maintained.

I've used AASM in the past, and it has been around a bit longer, but the state_machine gem has quite a bit more functionality and more options. e.g. check the methods generated by state_machine on the base class (below their example); you can define more details, e.g. transition callbacks, conditional transitions; you can do path analysis, there's even a GraphViz generator to generate a nice picture of your state graph.

If you need just a simple state machine, you can go with AASM. If you need to model more details like conditional transitions or transition callbacks, path analysis, do queries about the states a lot, or need nested state machines, then go for the state_machine gem.

References:

AASM : https://github.com/aasm/aasm

state_machine : https://github.com/pluginaweek/state_machine

Additional info about state_machine:

http://www.pluginaweek.org/2009/03/08/state_machine-one-machine-to-rule-them-all/

http://rdoc.info:8080/github/pluginaweek/state_machine/master/StateMachine/Machine

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top