class OrdersController
START:current_cart START:setup
Public Instance Methods
create()
click to toggle source
POST /orders POST /orders.json
START:create START:create
# File app/controllers/orders_controller.rb, line 42 def create @order = Order.new(order_params) @order.add_line_items_from_cart(@cart) respond_to do |format| if @order.save Cart.destroy(session[:cart_id]) session[:cart_id] = nil OrderNotifier.received(@order).deliver format.html { redirect_to store_url, notice: I18n.t('.thanks') } format.json { render :show, status: :created, location: @order } else format.html { render :new } format.json { render json: @order.errors, status: :unprocessable_entity } end end end
destroy()
click to toggle source
DELETE /orders/1 DELETE /orders/1.json
# File app/controllers/orders_controller.rb, line 83 def destroy @order.destroy respond_to do |format| format.html { redirect_to orders_url, notice: 'Order was successfully destroyed.' } format.json { head :no_content } end end
edit()
click to toggle source
GET /orders/1/edit
# File app/controllers/orders_controller.rb, line 35 def edit end
index()
click to toggle source
GET /orders
END:current_cart
GET /orders.json
# File app/controllers/orders_controller.rb, line 13 def index @orders = Order.all end
new()
click to toggle source
GET /orders/new
START:checkout
# File app/controllers/orders_controller.rb, line 24 def new if @cart.line_items.empty? redirect_to store_url, notice: "Your cart is empty" return end @order = Order.new end
show()
click to toggle source
GET /orders/1 GET /orders/1.json
# File app/controllers/orders_controller.rb, line 19 def show end
update()
click to toggle source
PATCH/PUT /orders/1 PATCH/PUT /orders/1.json
# File app/controllers/orders_controller.rb, line 69 def update respond_to do |format| if @order.update(order_params) format.html { redirect_to @order, notice: 'Order was successfully updated.' } format.json { render :show, status: :ok, location: @order } else format.html { render :edit } format.json { render json: @order.errors, status: :unprocessable_entity } end end end