An entity relationship diagram (ERD) shows the tables, columns and relations in a relational database schema. To auto-generate an ERD for a specific version of your code directly from the database, you can use the rails-erd
gem. It does this by:
- Gathering database meta data through active record (it uses ActiveRecord so it’s database independent).
- Analyzing the schema and then generating a DOT file, which can be processed into a PDF.
- Bundling all of this up into a rake task, which you can use to update the ERD when you modify the schema.