Tutorial - Use transactions to extract your Rails controller
24-Sep-2019 1544
When your Rails app needs to handle multiple steps, your controllers' methods can become a mess. Don't despair, though. You can delegate sequential steps to business transactions and Marie-Kondo those messy controllers. I'll show you how.Let's keep in mind that business transactions are different from ActiveRecord transactions. Business transactions allow you to create a series of steps, each resulting in a Success or a Failure object. ActiveRecord transactions are about ensuring that several database operations work as a single unit and are all rollbacked if any error occurs.In this tutorial, I'll use the dry-transaction gem whose documentation is neat.
Tutorial - Use transactions to extract your Rails controller #ruby #rubydeveloper #rubyonrails #Tutorial #transactions #extract #Rails #controller #tutorial https://rubyonrails.ba/link/tutorial-use-transactions-to-extract-your-rails-controller