This message was imported from the Ruby/Rails Modularity Slack server. Find more info in the import thread.
Message originally sent by slack user U729CX72B8B
Topic: Moving Rails Concerns - I noticed we had a long list of dependency violations for our Conversions concern (convert miles to meters, hours to minutes etc.) and decided to make a “utils” pack. Once I realized I’d have to go find all the places where Conversions methods were being called I got gun shy and moved it back. I’m very much in an experimental phase but wondered if/when you all started messing with mixins and concerns in your transition process?
I don’t think we’ve ever had a phase where we addressed mixins specifically, it’s just a part of solving violations in general. :man-shrugging:
If Conversions concern is generic enough, you could make it public and call it a day. However, personally I don’t like concerns at all, I’d rather have a public module with methods.
Agree, but do you have other alternatives besides copy/pasting code or exporting to a gem? Following the example converting things (Leora example) ?
Something I’d like is to have is shared across all the packs (like application controller, the job/worker base class).
Once I realized I’d have to go find all the places ….
Can you tell me what behavior you were seeing? Moving a constant into a different packs with bin/packs and packs-rails shouldn’t require you to actually change how a constant is defined. You can optionally choose to change the constant (e.g. nest a constant under the pack namespace), but it’s not actually necessary.
Typically at Gusto, I recommend folks move files/constants to different packs as an independent step before changing the constant module nesting and updating code that uses that constant. This lets you get incremental value (have code in the right place) without opening up a big can of worms.
let me try! I started experimenting with packwerk and use_packs (adding packs into our autoload_paths manually) to see what it gave, going to add packs-rails into the Gemfile now