Accidental Technologist

Musings about Entrepreneurship, Technology and Software Development

  • Home
  • About
  • Still River Software
  • Privacy Policy

Powered by Genesis

Dead Simple Model Diagrams for Your Rails Project

May 9, 2013 by Rob Bazinet 12 Comments

Tweet

While working on Rails project I often find myself wanting a visual representation of my model classes. ?I usually grab a notebook and manually write them out. Depending on the project, it can take time.

I started searching for a diagramming tool that might be easier and faster than writing out by hand, there are a bunch of them out there. ?Most have a steep learning curve and are expensive.

A bit of searching around the web for a Ruby-specific tool lead me to a gem named rails-erd. ?Maybe you have heard of it, maybe I’m the last to know, but regardless it is a nice find.

Installing

The gem relies on GraphViz to do it’s drawing magic. ?There are a multitude of ways to install it, I used Homebrew:

brew install graphviz

Add the gem to your development group in your Gemfile:

group :development do
?gem 'rails-erd'
end

Don’t forget to run the bundle command.

When everything is install, from the root of your Rails project simple run:

rake erd

When the rake task runs, watch the output from the tool. It tells you items you won’t find on the diagram either because it’s not used or a relationship isn’t right.

The Output

The result will be a PDF file in the root of your project that looks something like this:?

Erd

As you can see, it gives a very nice model diagram with all the relations and properties. Just what I was looking for.

The tool is very customizable and the web site outlines everything that can be changed. ?I haven’t looked very much at this aspect since it produced everything I needed the first time.

Share this:

  • LinkedIn
  • Twitter
  • Facebook
  • Email
  • More
  • Pinterest
  • Tumblr
  • Pocket
  • Reddit

Filed Under: Ruby on Rails Tagged With: diagrams, domain models, erd, models, Ruby on Rails

Recent Posts

  • How to Fix Rails Flash Rendering When Using Hotwire
  • Hotwire Fix for CORS Error when using Omniauth
  • Fix Installation of Ruby using rbenv on macOS Big Sur
  • RailsConf 2021 and the Future of Conferences
  • Fixing Out of Diskspace Errors on Amazon EC2

Categories

Services I Love

HatchBox - Easy Rails Deploys Fathom Analytics
Follow @rbazinet

Rob Bazinet (ruby.social/@rbazinet)
@rbazinet

  • Working to wrap up my current consulting gig by mid-April. I will be looking for the next thing soon. If anyone has… https://t.co/sg3cSV9yqM
    about 6 hours ago
  • I’ve been spending some time using Notion AI lately and it surprisingly good. Since all the rage lately is ChatGPT,… https://t.co/cUXFWIRCVV
    about 3 days ago
  • I think these steps are true for any target audience. https://t.co/0ht6rIzOW3
    about 3 days ago
  • I’ve been enjoying a show from the Magnolia network called The Craftsman. It’s mainly about woodworking but his phi… https://t.co/sWTUBbSsl6
    about 3 days ago
  • I found the resource I was looking for last night that is similar to https://t.co/Pyn0IIjRdP, it is… https://t.co/U7TMe77FMF
    about 3 days ago
  • RSS - Posts
  • RSS - Comments
Find me on Mastodon