martes, 9 de noviembre de 2010

Installing Rails-ERD on Rails 3

Hi all,
I was looking for something to make my DB diagrams based on my models with Rails, and waiting not to be painfull for me and my health.
So I found(thanks to my collegue Pablo Formoso) Rails-ERD a ruby gem that takes de relationships defined in the models and the tables defined in the database and generates with only one command all the diagram for you.

This is a step by step guide for intalling and execute this gem:

1.- First you will need to add the following to your gemfile:

gem "rails-erd"

Inside the block:

group :development do

end

This way you can call a rake task to generate the diagram in development environment.

2.-Use bundler to install the gem:

bundle install

3.-although in the installation instructions this point is not commented, I have been with
troubles for a while trying to generate the diagram and failing, and all happened because
when you install rails-erd the ruby-graphviz gem is installed to, but the graphviz library
doesn't, to solve this run one of the following commands(depending on you prefer) :

sudo port install graphviz

brew install cairo pango graphviz

sudo aptitude install graphviz


3.- Rake task to Generate the diagram:

rake erd

With this command the gem creates a pdf file inside your root app directory.

And that´s all, I wish this to be helpful for someone more.

There is a lot of parameters that can be added to this last command to modify its behavior.
You will find very useful information here

No hay comentarios: