Skip to content

Instantly share code, notes, and snippets.

@jrom
Created November 23, 2016 12:20
Show Gist options
  • Save jrom/0c4e4b73569e70f4780cd2898d664f8d to your computer and use it in GitHub Desktop.
Save jrom/0c4e4b73569e70f4780cd2898d664f8d to your computer and use it in GitHub Desktop.
Data model for Rails app using rails_erd
namespace :datamodel do
desc 'Generates data model in erd.pdf'
task :generate do
#say 'Loading application environment...'
Rake::Task[:environment].invoke
require 'rails_erd/diagram/graphviz'
#say 'Loading all models...'
Rails.application.eager_load!
::Rails::Engine.subclasses.map(&:instance).map {|e| e.class.eager_load!}
#say 'Generating erd.pdf...'
RailsERD::Diagram::Graphviz.create
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment