Created
June 18, 2013 13:36
-
-
Save beydogan/5805413 to your computer and use it in GitHub Desktop.
order create
This file contains 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
# POST /orders | |
# POST /orders.json | |
def create | |
@order = current_user.orders.new(params[:order]) | |
@order.add_line_items_from_cart(current_cart) | |
@order.payment.amount = @order.total_price | |
@order.payment.save | |
respond_to do |format| | |
if @order.save | |
Cart.destroy(session[:cart_id]) | |
session[:cart_id] = nil | |
format.html { redirect_to(@order, :notice => | |
'Thank you for your order.' ) } | |
format.xml { render :xml => @order, :status => :created, | |
:location => @order } | |
else | |
format.html { render :action => "new" } | |
format.xml { render :xml => @order.errors, | |
:status => :unprocessable_entity } | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment