Visualize your Rails database schema for free on Windows
Posted by Chirag Patel on August 9, 2007
Using Railroad and Graphviz
Blog update (10/22/2007): Thanks to the comment posted by Blog de Kilgore, I tried Railroad (instead of using the below method with starUML) to visualize my RoR app. Very easy to setup and use (see examples on web page).
Here’s a quick command to create a .png graphic file of your models:
railroad -a -i -M | dot -Tpng > models.png
This command will directly write to a .png file without the need of Graphviz
- Database Models
- Mailer models
- Observer models
- Associations (with lines and arrows)
- Inheritance among classes (for regular models, mailers, and observers)
Rails keeps your schema is a file called
db/schema.rb (which I assume is updated every time you run a Rails migration). To visualize your schema in Windows:
- Install and run the following plugin to convert your schema (
db/schema.rb) to an XML format:
ruby ./script/plugin install http://cnruby.googlecode.com/svn/trunk/plugins/uml
This will generate
schema.xml(uses a open standard fromat called XMI).
- Download the latest version of starUML for Windows (Version 5.0, released Dec 29, 2005). StarUML is a "software modeling tool and also platform that is a compelling replacement of commercial UML tools such as Rational Rose"
Thanks to Miroslav Škultéty for writing the script and cnruby for converting into a plugin!