Accidental Technologist

Musings about Entrepreneurship, Technology and Software Development

  • Home
  • About
  • Still River Software
  • Privacy Policy

Powered by Genesis

You are here: Home / Ruby on Rails / Dead Simple Model Diagrams for Your Rails Project

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

Related

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

Care about your privacy? I do and use Fathom Analytics on this site.

Fathom Analytics

Recent Posts

  • Status Bar in iTerm2
  • Supporting Multiple SSH Keys on macOS
  • Using the Microsoft Ergonomic Keyboard on macOS
  • 10 Steps to Survive Working from Home
  • “Are you building a business or learning a stack?”

Categories

Services I Love

HatchBox - Easy Rails Deploys Fathom Analytics
Follow @rbazinet

Rob Bazinet
@rbazinet

  • Spending the evening working on some new Ruby on Rails code. As one with no life does on a Saturday night.
    about 8 hours ago
  • I have me daily hike listening scheduled. https://t.co/IpEMqk5KXk
    about 18 hours ago
  • I’ve been contemplating creating a newsletter for a long time. It would be for Ruby developers and highlight variou… https://t.co/zb3b4sF2yd
    about 18 hours ago
  • This! https://t.co/SYXR9eE9Ls
    about 19 hours ago
  • I’ve spent the last year working on a handful of Ruby on Rails enterprise applications. I’ve learned a ton and real… https://t.co/RHU1kbrlRq
    about 2 days ago
  • RSS - Posts
  • RSS - Comments
loading Cancel
Post was not sent - check your email addresses!
Email check failed, please try again
Sorry, your blog cannot share posts by email.