Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create ERD type diagrams from Rails code

I'm beginning to learn Ruby on Rails, and looking at other peoples code. Is there any way to take an exisiting codebase and create object relationship diagrams or Entity relationship diagrams (ERD's) ?

I know Visio can do some things given a database, but I was hoping to produce diagrams of classes and objects.

like image 489
PaulHurleyuk Avatar asked Mar 18 '09 22:03

PaulHurleyuk


People also ask

What is rail ERD?

Rails ERD is a gem that allows you to easily generate a diagram based on your application's Active Record models. The diagram gives an overview of how your models are related. Having a diagram that describes your models is perfect documentation for your application.

Is ERD same as class diagram?

Class diagrams and ERDs both model the structure of a system. Class diagrams represent the dynamic aspects of a system: both the structural and behavioural features. ERDs, depicting only structural features provide a static view of the system. A class is a general concept (represented as a square box).

Is ERD a type of UML diagram?

The main difference between UML and ERD is that UML is a modeling language that represents a system or a software visually while ERD is a diagram that represents the entities and their relationships in a database. In brief, there are many diagrams in UML and, ERD itself is a UML diagram.


4 Answers

Also Rails ERD is not bad. It is a bit simpler than Railroad but it is still a great project.

like image 53
lzap Avatar answered Sep 19 '22 16:09

lzap


You may want to check out Railroad. It takes your Rails project and visualizes it. It can create diagrams based off of your models (based off of has_many, has_and_belongs_to_many, etc), controllers (based on inheritance hierarchy) and state machine diagrams, which I have never used.

But it is pretty cool and does what it is supposed to. It may not have all the flair that Visio has but it is a darn good solution.

like image 37
vrish88 Avatar answered Sep 21 '22 16:09

vrish88


Some IDE's have this feature, if I remember rightly RubyMine does.

like image 26
Kris Avatar answered Sep 19 '22 16:09

Kris


Rails ERD has excellent documentation and gallery: http://rails-erd.rubyforge.org/gallery.html

like image 34
joelparkerhenderson Avatar answered Sep 21 '22 16:09

joelparkerhenderson