Class: Cartify::OrderItemsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/cartify/order_items_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



5
6
7
8
9
# File 'app/controllers/cartify/order_items_controller.rb', line 5

def create
  current_order.save
  @order_item = current_order.order_items.find_or_initialize_by(product_id: order_item_params[:product_id])
  session[:order_id] = current_order.id if update_quantity.save
end

#destroyObject



17
18
19
20
21
# File 'app/controllers/cartify/order_items_controller.rb', line 17

def destroy
  @order_item = current_order.order_items.find(params[:id])
  @order_item.destroy
  @order_items = current_order.order_items
end

#updateObject



11
12
13
14
15
# File 'app/controllers/cartify/order_items_controller.rb', line 11

def update
  @order_item = current_order.order_items.find(params[:id])
  @order_item.update_attributes(order_item_params)
  @order_items = current_order.order_items
end