How to Visualize Your Rails ERD Diagram Instantly

Rails comes with a schema.rb file that contains a clear definition of your database tables and how they're linked together. But what if you want to generate an entity-relationship diagram (ERD) of your Rails app to quickly get a sense of how they look?

Since we launched dbdiagram.io, a free and simple tool to draw entity relationship diagram 4 weeks back, we've been getting tons of feedback. Among those, a lot of people are asking if we support integrations with Rails, Django, or Laravel.

So today I'm excited to share that we've fulfilled one of the first steps: we now support Rails! If you are a Rails developer, you can quickly generate a database relationship diagram (or ERD diagram) from your schema.rb, in just 3 simple steps:

  1. Open dbdiagram.io
  2. Click Import → From Rails (schema.rb)
  3. Paste (or upload) your schema.rb
  4. Profit!

Some cool features that the tool has:

  • Auto recognize your Rails relationship: It reads both explicit and implicit foreign key definitions (and convention), then translates them to the correct relationships. Explicit definitions like add_foreign_key() or t.references 'user' are recognized; implicit (convention) definition like t.integer user_id are also recognized!
  • You can generate a beautiful PDF file afterwards.
  • It's completely free!

If you want to give it a try, go to dbdiagram.io and upload your schema.rb to see how your rails erd diagram look.