Loading 6 Votes - +

Visualize Ruby on Rails Model Associations with rails_assviz

Rails is a nice framework because it does its best to keep things simple. However, even the simplest framework can get cumbersome as an application grows. As I was tweaking some of the Rails code that powers OmniNerd, I was wishing I had a simple command line script that would draw a picture of OmniNerd’s model associations for me. Well, I wished for about 5 minutes and then I fired up TextMate and got to writing. The image you see is the result.

2_article_2756_thumb_dot_erd

OmniNerd’s model associations.

Each line or “edge” between nodes calls out a relation between two “models.” In Rails, models define various objects that ultimately get stored in a database. As you can see, there are a lot of associations.

The cool thing about this script is that it’s insanely useful and only took about 60 lines of “real” code (and about 100 lines of “housekeeping” code). I put the code on github and gave it the name rails_assviz. 1 The name just came to me. Rails associations … assviz. It’s perfect.

If you hack on Ruby, feel free to send me input on how to make this better. For now, it serves my needs. Hopefully someone else will find it useful as well.

Notes

1 rails_assviz is available on github. http://github.com/markmcb/rails_assviz/tree/master

Similarly tagged OmniNerd content:

Thread parent sort order:
Thread verbosity:

I needed something like this about a year ago, and a web search turned up RailRoad, which generates “dot” format files from Rails models.

Share & Socialize

What is OmniNerd?

Omninerd_icon Welcome! OmniNerd's content is generated by nerds like you. Learn more.

Voting Booth

Dzhokar Tsarnaev deserves due process?

32 votes, 4 comments