Last active
August 29, 2015 14:02
-
-
Save rocodev-tech/6b340e2ce5877fe5b9da to your computer and use it in GitHub Desktop.
app/controllers/orders_controller.rb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class OrdersController < ApplicationController | |
| before_action :authenticate_user! | |
| def create | |
| @order = current_user.orders.build(order_params) | |
| if @order.save | |
| @order.build_item_cache_from_cart(current_cart) | |
| @order.calculate_total!(current_cart) | |
| redirect_to root_path | |
| else | |
| render "carts/checkout" | |
| end | |
| end | |
| private | |
| def order_params | |
| params.require(:order).permit(:info_attributes => [:billing_name, :billing_address,:shipping_name, :shipping_address] ) | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment