Tool to generate state transition diagram for acts_as_state_machine

1.6k Views Asked by At

The ruby gem acts_as_state_machine can be super helpful for modeling object lifecycles within a flexible finite state machine framework. But I often find myself wanting a visual representation of the state transitions.

Is there a tool to generate an FSM diagram (state diagram flowchart, state/event table, UML, etc.) from an existing ruby class that acts_as_state_machine?

4

There are 4 best solutions below

0
On BEST ANSWER

The state_machine gem (not to be confused with acts_as_state_machine) has this functionality.

For example, from the docs:

$ rake state_machine:draw FILE=vehicle.rb CLASS=Vehicle

state_machine is no longer maintained. Its fork state_machines has extracted diagram functionality into a separate gem state_machines-graphviz. Installing that gem, and then run the renamed rake task:

$ rake state_machines:draw FILE=vehicle.rb CLASS=Vehicle
0
On

https://github.com/padde/stateoscope gem works with the AASM gem (previously known as acts_as_state_machine)

0
On

Check aasm-diagram gem, seems newer.

0
On

A very late response but I'm using AASM and I've got the same problem. Forget about the state_machine gem. It hasn't been updated for 4 years now and doesn't look like it ever will. The best option I've found for AASM, is to download OpenOffice and use the OpenOffice Draw tool to generate a flow diagram. OpenOffice is free and it's very easy to use.

Obviously it would be far better if this was supported internally by AASM. Unfortunately it isn't.