Saturday, May 12, 2007

Visualize Models 1.1

Visualize Models is a small rake script that will generate .png images for Ruby On Rails models (i.e. the database tables) that will display the table/column information. The associations between tables is based on the default Ruby On Rails naming convention (i.e. <table>_id columns). See image below for the typo blog models:

Typo Blog

Install as a plugin. From your rails application root, run
ruby script/plugin install svn://rubyforge.org//var/svn/visualizemodels/visualize_models
Run the plugin with:
rake visualize_models
This plugin depends on GraphViz, which you can find here.

If you're a Mac user, the Darwin port of GraphViz seems to work better. Just do:

 sudo port install graphviz

This program has its roots in the Annotate Models by Dave Thomas. See also the RubyForge project page for additional info.

In addition to Visualize Models there are two (that I'm aware of) other projects that you can use to visualize the database in Ruby On Rails:

If you know about any additional resources to visualize rails models, please drop me a mail at nils@<this domain>.

Update: Fixed the ActiveSupport::Inflector in SVN now as noted in the comments. Visualize_models works out of the box for rails 2.2.2 and later now

8 comments:

Jie Dai said...

I have have installed grapviz on my windows XP and Visualize Models. But when I do rake visualize_models, it looked at all my tables but "failed to execute the 'neato' command"

nilsf said...

Make sure that neato and dot is in your path and that you can start them from the command prompt.

ian said...

Cheers for this plugin. It's been very useful

David Medinets said...

First, thanks for the plugin! After installation, I ran into a problem that Visualize::Inflector was not found. This was easily resolved by using ActiveSupport::Inflector in visualize_models.rb.

sacredceltic said...

I'm a newbie on RoR and I get the message error 'Visualize::Inflector was not found' and I don't understand David medinets comment on how to address that. I can't find any reference to 'Inflector' in the .rb file.
I run on Mac OSX and the command "sudo port install graphviz" doesn't work either..

Gudata said...

‘Visualize::Inflector was not found’ - it appears with the rails = 2.2.2, switch to 2.1 to generate your models if you are in hurry

Ron b said...

Is there a way to pass parameters with this class. I would like to do some of the tables in the model. Current it does ever table.

Jason F said...

sacredceltic: look in the visualize_models.rb file, and replace every "Inflector" with "ActiveSupport::Inflector". That should fix your error.

Post a Comment