The project is in a healthy, maintained state
Generate Mermaid-based ERD diagrams for ActiveRecord models with their dependencies
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Development

~> 2.0
~> 13.0
~> 3.0
~> 1.4

Runtime

 Project Readme

ActiveRecordERD

Generate Entity Relationship Diagrams (ERD) for your ActiveRecord models using Mermaid syntax.

Installation

Add this line to your application's Gemfile:

gem 'activerecord-erd'

And then execute:

$ bundle install

Or install it yourself as:

$ gem install activerecord-erd

Usage

This gem adds erd methods to all your ActiveRecord models:

# Generate an ERD diagram for the User model (class level)
User.erd

# Generate an ERD diagram for a specific user instance
user = User.find(1)
user.erd

# Include empty relationships in the diagram
User.erd(empty: true)

The ERD is generated using Mermaid syntax, which can be rendered in many Markdown viewers including GitHub.

Features

  • Visualize model relationships with detailed information
  • Show foreign keys and their reference counts
  • Distinguish between simple and complex dependencies
  • Support for has_many, has_one, belongs_to, and through associations
  • Instance-specific diagrams that show only related records

Development

After checking out the repo, run bin/setup to install dependencies. You can also run bin/console for an interactive prompt.

To install this gem onto your local machine, run bundle exec rake install.

Contributing

Bug reports and pull requests are welcome on GitHub. This project is intended to be a safe, welcoming space for collaboration.

License

The gem is available as open source under the terms of the MIT License.