6 Nerd-Its - +

Visualize Ruby on Rails Model Associations with rails_assviz

Page_white_text an academic article by Mark A. McBride (markmcb), published on 21 June 2009
tagged as rails, graphviz, visualization, model, and railsassviz
other nerds have left 2 comments below

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

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.

OmniNerd Article Propagation

The Showcase

Nerd-Its   Nerd Trends   Last Ten  

  1. wonder in Mosque construction at Ground Zero?
  2. RE: Be very afraid in Which agency scares you the most?
  3. RE: just wondering in Peanut Wars: Inconvenience vs. Death
  4. RE: just wondering in Peanut Wars: Inconvenience vs. Death
  5. RE: Uneven water coverage? Not an issue in How To Install an Underground Sprinkler System on a Budget
  6. RE: just wondering in Peanut Wars: Inconvenience vs. Death
  7. RE: just wondering in Peanut Wars: Inconvenience vs. Death
  8. RE: just wondering in Peanut Wars: Inconvenience vs. Death
  9. RE: Uneven water coverage? Not an issue in How To Install an Underground Sprinkler System on a Budget
  10. RE: just wondering in Peanut Wars: Inconvenience vs. Death

What is OmniNerd?

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

Voting Booth

Which agency scares you the most?

13 votes, 4 comments