Auto-generate state_machine graphs as PNG images

Updated . Posted . Visible to the public.

The state_machine gem Show archive.org snapshot comes with a rake task that lets you generate PNG graphs from any model using state_machine.

Install the required dependencies like this:

sudo apt-get install graphviz
sudo gem install ruby-graphviz

You can now generate a graph like this:

rake state_machine:draw CLASS=ModelUsingStateMachine

Replace ModelUsingStateMachine with the name of your model class.


If it the raketask does not exist for you, add to Rakefile (in your project root):
require 'tasks/state_machine'

Henning Koch
Last edit
License
Source code in this card is licensed under the MIT License.
Posted by Henning Koch to makandra dev (2011-09-12 15:59)