Rails Entity-Relationship Diagrams
Published: Mar 17, 2022
Last updated: Mar 17, 2022
This post will look into the rails-erd
Source code can be found here
Getting started
In this particular post, we will make use of another project worked on demo-rails-associations
in "Understanding Rails Associations"
# Create a new rails project $ git clone https://github.com/okeeffed/demo-rails-associations.git $ cd demo-rails-associations # Add the gem $ bundle add rails-erd
After cloning the project, we just need to add the rails-erd
gem and we are basically home and hosed.
Generating the diagram
At this point, all we need to do to output a diagram is to run bundle exec erd
.
That will output a PDF file erd.pdf
. The output will outline the following from the relationships we created in the previous posts:
Output ERD
Summary
Today's short post demonstrated how to generate the entity-relationship diagram for the Rails models using rails-erd
.
Resources and further reading
Photo credit: pawel_czerwinski
Dennis O'Keeffe
Melbourne, Australia
1,200+ PEOPLE ALREADY JOINED ❤️️
Get fresh posts + news direct to your inbox.
No spam. We only send you relevant content.
Rails Entity-Relationship Diagrams
Introduction