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.
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.
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).
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.
Also Rails ERD is not bad. It is a bit simpler than Railroad but it is still a great project.
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.
Some IDE's have this feature, if I remember rightly RubyMine does.
Rails ERD has excellent documentation and gallery: http://rails-erd.rubyforge.org/gallery.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With