This card explains how to generate an entity relationship diagram for your Rails application.
We also show how to limit your ERD to a subset of models, e.g. models inside a namespace.
bundle exec rake erd
This is not directly possible with RubyMine. While you can manually remove boxes in the generated diagram, this is cumbersome on large projects, and can't be automated.
You can use rails-erd instead.
As an example, here is a Rake task where we render only Models inside the DataMigration
module.
namespace :data_migration do
task erd: :environment do
Rails.application.eager_load!
require 'rails_erd/domain'
require 'rails_erd/diagram/graphviz'
model_names = RailsERD::Domain
.generate(warn: false)
.entities
.map(&:model)
.map(&:name)
.grep(/^DataMigration::/)
filename = RailsERD::Diagram::Graphviz.create(
only: model_names,
title: 'DataMigration ERD',
# You may add further options here. Example:
attributes: ['foreign_keys', 'primary_keys'],
filename: 'data_migration_erd',
indirect: true,
orientation: 'vertical',
warn: false,
)
puts "Generated #{filename}"
end
end
$ rake data_migration:erd
Generated data_migration_erd.pdf
For more configuration options, see the rails-erd customizing guide Show archive.org snapshot .