Capturing the Order Details

Learn to get user details for order confirmation.

Feel free to make other changes, but only the first is currently used in the functional tests. For these tests to pass, we’ll need to implement the model.

Let’s implement the create() action in line 1 in the orders_controller.rb. This method has to do the following:

  1. Capture the values from the form to populate a new Order model object.

  2. Add the line items from our cart to that order.

  3. Validate and save the order. If this fails, display the appropriate messages and let the user correct any problems.

  4. Once the order is successfully saved, delete the cart, redisplay the catalog page, and display a message confirming that the order has been placed.

Get hands-on with 1200+ tech skills courses.