Refactoring code is an important part of software development and there are many opportunities for refactoring in the Reflektive codebase. In this challenge, you will be presented with a complicated controller action that could benefit from refactoring.
The application is a typical e-commerce app. The controller action you will be refactoring is the order creation endpoint OrdersController#create
.
For our application, we have Product
s with a price
attribute. We have shopping Cart
s that have many Product
s through the OrderedItem
s join table. An OrderedItem
belongs_to
a Cart
and a Product
. It has a quantity
attribute to keep track of the number of products ordered.
The OrderedItem
also belongs_to
an Order
. This association will be made upon checkout when it's associated with an Order
.