July 25, 2012 - 1 comment.

Visualize Your Schema with the Erd Gem

Before stepping into the Railsconf 2012 lightning talks, the last time I saw a database schema visualizer was when Microsoft Access 97 was cool. Okay, that time may never have existed, but I can verify that I personally haven't run into too many visualizers since those days. Enter the fine cookpad engineers who came all the way from the Land of the Rising Sun for Railsconf festivities, including the lighting presentation of a fun gem called erd. It gives you a graphic birds-eye-view of your schema and it's pretty easy to use:

[powershell gutter="false"]
gem install erd
[/powershell]

Then start rails server and look for the magic at localhost:3000/erd

If you get the following error:

[powershell gutter="false"]
Saving diagram failed!
Verify that Graphviz is installed and in your path, or use filetype=dot.
You'll want to download and install Graphviz
(hombrew users can 'brew install graphviz')
[/powershell]

I find erd handy when trying to understand a new project quickly. Let's say I want to see how a simple blog application, enki, thinks about its data.

After following the install instructions and installing the erd gem*, we see the fruits of our labors:

Not bad. Gives a nice overview of the schema and jumping off point for understanding a new project. It even has (fledgling) support for editing the schema and generating rails migrations.

Which Access 97 feature shall we port to rails next?

* I also needed to comment out a clashing route:

[ruby]
scope :to => 'posts#index' do
get 'posts.:format', :as => :formatted_posts
#get '(:tag)', :as => :posts
end
[/ruby]

Photo Credit: John Parker

Published by: Erik Schwartz in Business, Developers
Tags: , , , ,

Comments

kue balok
January 14, 2016 at 5:09 pm

niche thread, i like’t.

Leave a Reply