bridge_troll
bridge_troll copied to clipboard
Generating an ERD (entity relationship diagram) for the project would help developers get started
In my ruby_on_racetracks branch, I have rails-erd installed. When I run the command "bundle exec erd --attributes=foreign_keys,primary_keys,timestamps,inheritance,content --filetype=dot --filename=tmp/diagram-models --inheritance --notation=bachman dot -Tjpg tmp/diagram-models.dot", I get the following error messages:
Loading application in 'bridge_troll'...
Generating entity-relationship diagram for 26 models...
Warning: Ignoring invalid association :role on Rsvp (model Role exists, but is not included in domain)
Warning: Ignoring invalid association :volunteer_assignment on Rsvp (model VolunteerAssignment exists, but is not included in domain)
Warning: Ignoring invalid association :operating_system on Rsvp (model OperatingSystem exists, but is not included in domain)
Warning: Ignoring invalid association :volunteer_preference on Rsvp (model VolunteerPreference exists, but is not included in domain)
Diagram saved to 'tmp/diagram-models.dot'.
Error: in routesplines, cannot find NORMAL edge
Segmentation fault (core dumped)
rails-erd seems to have difficulty with ActiveHash::Base types.
I like the idea of generating an entity relationship diagram. I wonder if this is something that is a bug in rails-erd and ActiveHash...
IIRC, ActiveHash isn't actually stored in the database, but gets its data from a yaml, so it may be something not yet supported by rails-erd
I got this working. First I checked to see if PDF output works:
- Following the README for rails-erd I first installed Graphviz with
brew install graphviz
- I added the following lines to my Gemfile in
group :development do
:
gem 'rails-erd'
gem 'ruby-graphviz'
- Then I ran
bundle install
,bundle exec rails-erd
and it generated a pdf file. I did get warnings similar to those above, but it completed successfully.
Then I tried the query as posted in the original post; it generated the diagram-models.dot
file and also spewed a bunch of binary data into my terminal. I amended the command to redirect the output to a jpg and that jpg is valid. So, the command I ran was bundle exec erd --attributes=foreign_keys,primary_keys,timestamps,inheritance,content --filetype=dot --filename=tmp/diagram-models --inheritance --notation=bachman dot -Tjpg tmp/diagram-models.dot > thing.jpg
and I got below as results:
(And a .dot file GitHub doesn't support)
How would y'all like to proceed? Do we just want these docs for people to read, or do we want to build this functionality into the project?
Build the functionality into the project, but keep the outputs out of the source code in the interest of keeping the code base small.
Can you describe in greater detail how you envision that working? Do we install Graphviz as a requirement of the project and include a wrapper script that executes that command, and some documentation explaining to open the resulting jpg?
After discussing with @nerual, we were not sure of the benefits of including this feature in the project without extensive training on how to use it and for what instances. It seems like this feature request is an individual preference rather than in the scope of the needs of the Bridge Troll project. In the interest of keeping the development
gemset lean, we would prefer not to include this if only one contributor would be using it once to generate a document.
An option is for @jhsu802701 to create a pull request documenting how one would generate this document following the steps @nerual outlined above as a resource for any new developers.