diff --git a/app/assets/stylesheets/store.scss b/app/assets/stylesheets/store.scss index 42f062a..e50e369 100644 --- a/app/assets/stylesheets/store.scss +++ b/app/assets/stylesheets/store.scss @@ -37,6 +37,10 @@ margin-left: 100px; margin-top: 0.5em; margin-bottom: 0.8em; + + form, div { + display: inline; + } } .price { diff --git a/app/controllers/line_items_controller.rb b/app/controllers/line_items_controller.rb index 1341422..b41c2f1 100644 --- a/app/controllers/line_items_controller.rb +++ b/app/controllers/line_items_controller.rb @@ -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 } diff --git a/app/views/carts/show.html.erb b/app/views/carts/show.html.erb index 32f7a23..a3d8b09 100644 --- a/app/views/carts/show.html.erb +++ b/app/views/carts/show.html.erb @@ -1,4 +1,9 @@
<%= notice %>
-<%= link_to 'Edit', edit_cart_path(@cart) %> | -<%= link_to 'Back', carts_path %> +