collin,
@collin@ruby.social avatar

Can anyone recommend me a data model visualizer that works with ? Ideally I can drop my schema.rb on it and get something that turns that into showing me all of the relationships and properties. If it was similar to this screenshot of the Core Data modeler, that would be awesome.

veganstraightedge,
@veganstraightedge@ruby.social avatar

@collin Adding to the +1s for rails-erd…

I just (re-)fired it up on the CrimethInc. website codebase and first things first, it revealed to me that we have a model without a table.

TODO:
Confirm model is unused, delete it OR
Confirm it's used, don't inherit from ApplicationRecord

In addition to a useful diagram, I learned about (probably) dead code! 🎉

caleb,

@collin Takes some massaging but rails-erd is quite nice. I’ve found several bugs with it in the form of relationships that were misconfigured. It boots your app and looks at each model’s actual associations (and fields, which adds a lot of noise).

collin,
@collin@ruby.social avatar

@caleb Yeah, there was definitely a lot of noise. I might play with it more since so many people seem to like it. My main issue was that where it placed things in the PDF clearly isn't random, but also is kind of hard for me to make sense of, and I'm not sure how I'd tell it to do differently.

caleb,

@collin I find it’s best to hand it an allowlist of models and omit fields entirely. That way I can say “here’s how this subsystem works” and I commit the .dot and .png as artifacts.

caleb,

@collin for placement it’s based on graphviz’s algorithms which are not random but are not able to be influenced easily.

collin,
@collin@ruby.social avatar

@caleb totally. I think figuring out how to isolate it to a few models will probably get me what I need.

caleb,

@collin I’ve been known to just hand-roll .dot files (not to be confused with dotfiles) to accomplish what I want.

hacrods,

@collin I use rails-erd gem for several years!
When your DB gets too big it gets messy, but that is a side effect of a large app DB diagram!
https://github.com/voormedia/rails-erd

stetsonthree,

@collin I’ll happily add another +1 to the recommendations for rails-erd. It proved repeatedly useful when I took over a legacy codebase with a subpar data model. And I plan to use it in future projects.

danhealy,

@collin rails-erd gem. It's pretty good, and customizable, but it can sometimes generate very busy diagrams. It uses the schema as well as the associations defined in the model. https://github.com/voormedia/rails-erd

Paul,

@collin I add this green to basically every project I work on: https://github.com/voormedia/rails-erd

collin,
@collin@ruby.social avatar

@Paul this looks really good. I’m going to give it a shot. I spent a good part of the day making my brain hurt trying to keep how everything is connected in my head 😂

mcphat,
@mcphat@ruby.social avatar

@collin I don't know if you're still using RubyMine at all, but there's one build in there.

collin,
@collin@ruby.social avatar

@mcphat is there? I must have missed that. I’ll look again.

mcphat,
@mcphat@ruby.social avatar

@collin "Rails Model Dependency Diagram" seems to be the ticket.

collin,
@collin@ruby.social avatar

@mcphat thanks! You’re a lifesaver.

mcphat,
@mcphat@ruby.social avatar

@collin Glad it helped!

mcphat,
@mcphat@ruby.social avatar

@collin Trying to find it... I've used it before.

mcphat,
@mcphat@ruby.social avatar

@collin Okay. Settings -> Tools -> Diagrams. Check the boxes for "Ruby Class Diagrams”

Then, right click a class in the file viewer pane on the right, and choose “Show Diagram" and choose what you want from the pop up.

This doc seems to have the info: https://www.jetbrains.com/help/ruby/working-with-diagrams.html#class_diagram

citizen428,

@collin @mcphat https://www.jetbrains.com/help/ruby/creating-diagrams.html I haven’t used RubyMine since 2015 or so but this is one feature I sometimes miss.

command_tab,
@command_tab@hachyderm.io avatar

@collin I’ve used this in Python land: https://github.com/Alexis-benoist/eralchemy I’ve never used its dependency, GraphViz, but maybe something similar could be cobbled together for Rails.

  • All
  • Subscribed
  • Moderated
  • Favorites
  • rails
  • DreamBathrooms
  • mdbf
  • ngwrru68w68
  • magazineikmin
  • thenastyranch
  • rosin
  • khanakhh
  • osvaldo12
  • Youngstown
  • slotface
  • Durango
  • kavyap
  • InstantRegret
  • tacticalgear
  • anitta
  • ethstaker
  • provamag3
  • cisconetworking
  • tester
  • GTA5RPClips
  • cubers
  • everett
  • modclub
  • megavids
  • normalnudes
  • Leos
  • JUstTest
  • lostlight
  • All magazines