The ERD shown at the dev_toolbar link should be synced with the project database. Because resyncing requires running rake erd, we need some instructions for regenerating the data model. Also, we should not host the erd in the public folder since that makes it accessible on prduction.
Solution
Create an engine and RCAV with instructions for running rake erd and showing the erd.png file at the root path. Separately, on https://github.com/firstdraft/project-syncing/pull/19, the gem version is bumped and the bundle exec rails g erd:install was run to add the auto generating of the ERD to any rake db: task (i.e., there will be no need to rake erd following a rake db:migrate).
Then bundle install and start up the server. Run bundle exec rails g erd:install to create the auto generator that will run on rake db:migrate. (This will be added to all projects following the updates here on https://github.com/firstdraft/project-syncing/pull/19)
Create some models with the commands in this lesson and rake db:migrate to see the new ERD link in the DevToolbar.
Add an association and rake erd then refresh the /erd route to see the update.
[!IMPORTANT]
Adds ERD generation instructions and updates DevToolbar to conditionally display ERD link.
Behavior:
Renames "Data Model" link to "ERD" in README.md and middleware.rb.
Adds ErdController in erd_controller.rb to handle ERD display.
Adds show.html.erb to display ERD instructions and image.
Ensures "ERD" link only appears if erd.png exists in middleware.rb.
Routing:
Adds route for /erd in engine.rb.
Misc:
Bumps version to 2.0.0 in version.rb.
This description was created by for 5da6e28e5b45d09b6c201e02484e87911af49d18. It will automatically update as commits are pushed.
Related to https://github.com/firstdraft/appdev/issues/633
Resolves #6
Problem
The ERD shown at the dev_toolbar link should be synced with the project database. Because resyncing requires running
rake erd
, we need some instructions for regenerating the data model. Also, we should not host the erd in the public folder since that makes it accessible on prduction.Solution
Create an engine and RCAV with instructions for running
rake erd
and showing theerd.png
file at the root path. Separately, on https://github.com/firstdraft/project-syncing/pull/19, the gem version is bumped and thebundle exec rails g erd:install
was run to add the auto generating of the ERD to anyrake db:
task (i.e., there will be no need torake erd
following arake db:migrate
).Testing
To test, open an appdev-projects repository in a codespace (use this one: https://github.com/appdev-projects/msm-queries), and change the
dev_toolbar
line in the Gemfile to:Then
bundle install
and start up the server. Runbundle exec rails g erd:install
to create the auto generator that will run onrake db:migrate
. (This will be added to all projects following the updates here on https://github.com/firstdraft/project-syncing/pull/19)Create some models with the commands in this lesson and
rake db:migrate
to see the new ERD link in the DevToolbar.Add an association and
rake erd
then refresh the/erd
route to see the update.