DEV Community

Discussion on: How to use transactions to unclutter your Rails controllers

Collapse
 
codenamev profile image
Valentino Stoll • Edited

I think the naming that the dry-transactions gem uses is definitely throwing people here (and I think missing the point Rémi is trying to make). This is less about wrapping code chunks in database transactions, and more about extracting business logic into processable steps to better align with how operators of the business perceive the flow of their clients (users).

I've used a couple other gems (namely trailblazer, and waterfall) which provide an entire framework for taking this idea a step further. Having worked with Trailblazer the most recent, I can say that simply having a rigid structure for processing data through chainable events (as is done in this great article) was an incredible dev experience that clearly defined a picture of what was happening and why.

Rails controllers are great for gathering data and directing it to the right pipeline, but I can't say I've come across anything remarkable in Rails that helps establish these pipelines.

Collapse
 
mercier_remi profile image
Rémi Mercier

I wouldn't have been able to explain this better. Thanks @codenamev for this great explanation and the kind words!