This is a tool to find association paths between different models in a rails app.
Example output - the paths from Job to Invoice:
[3] pry(main)> G.from(Job).to(Invoice)
Job.active_fleet_managed_invoice_from_swoop -- Invoice
Job.invoice >- Invoice
Job.owning_company >- Company.fleet_managed_clients -- FleetCompany.end_user_invoices -< Invoice
<snip - many more>
The edge digraphs show the arity of the associations.
--
one-to-one>-
many-to-one-<
one-to-many
Note: many to many (has_many :through) is shown with the join table included e.g.
Job.fleet_dispatcher >- User.invoices -< Invoice
Installation / Usage
- Add rgl to your Gemfile
gem 'rgl', group: :delevopment
- Run
bundle
- Save
build_model_graph.rb
to your project directory - open the rails console with
rails c
- Import the model graph file into the console
load 'build_model_graph'
- Query the graph for the paths between two models
G.from(Job).to(Invoice)