|
|
|
@@ -1,6 +1,10 @@ |
|
|
|
class LineItemsController < ApplicationController |
|
|
|
include CurrentCart |
|
|
|
before_action :set_cart, only: [:create] |
|
|
|
before_action :set_line_item, only: [:show, :edit, :update, :destroy] |
|
|
|
|
|
|
|
# TODO: Create counter from play time. |
|
|
|
|
|
|
|
# GET /line_items |
|
|
|
# GET /line_items.json |
|
|
|
def index |
|
|
|
@@ -24,11 +28,12 @@ class LineItemsController < ApplicationController |
|
|
|
# POST /line_items |
|
|
|
# POST /line_items.json |
|
|
|
def create |
|
|
|
@line_item = LineItem.new(line_item_params) |
|
|
|
product = Product.find(params[:product_id]) |
|
|
|
@line_item = @cart.line_items.build(product: product) |
|
|
|
|
|
|
|
respond_to do |format| |
|
|
|
if @line_item.save |
|
|
|
format.html { redirect_to @line_item, notice: 'Line item was successfully created.' } |
|
|
|
format.html { redirect_to @line_item.cart, notice: 'Line item was successfully created.' } |
|
|
|
format.json { render :show, status: :created, location: @line_item } |
|
|
|
else |
|
|
|
format.html { render :new } |
|
|
|
|