Skip to content

Instantly share code, notes, and snippets.

@Nitesh9952
Nitesh9952 / README.md
Last active April 4, 2020 19:32
Code Refactoring | Rails

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.

Data model overview

For our application, we have Products with a price attribute. We have shopping Carts that have many Products through the OrderedItems 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.