Read more

Auto-generate state_machine graphs as PNG images

Henning Koch
September 12, 2011Software engineer at makandra GmbH

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.

Illustration online protection

Rails Long Term Support

Rails LTS provides security patches for old versions of Ruby on Rails (2.3, 3.2, 4.2 and 5.2)

  • Prevents you from data breaches and liability risks
  • Upgrade at your own pace
  • Works with modern Rubies
Read more Show archive.org snapshot

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'

Posted by Henning Koch to makandra dev (2011-09-12 17:59)