Browse Source

Iteration F2.

master
Nils Dittberner 9 years ago
parent
commit
1e39309cfc
3 changed files with 3 additions and 1 deletions
  1. +1
    -0
      app/controllers/line_items_controller.rb
  2. +1
    -0
      app/views/line_items/create.js.erb
  3. +1
    -1
      app/views/store/index.html.erb

+ 1
- 0
app/controllers/line_items_controller.rb View File

@@ -34,6 +34,7 @@ class LineItemsController < ApplicationController
respond_to do |format| respond_to do |format|
if @line_item.save if @line_item.save
format.html { redirect_to @line_item.cart } format.html { redirect_to @line_item.cart }
format.js
format.json { render :show, status: :created, location: @line_item } format.json { render :show, status: :created, location: @line_item }
else else
format.html { render :new } format.html { render :new }


+ 1
- 0
app/views/line_items/create.js.erb View File

@@ -0,0 +1 @@
$('#cart').html("<%=j render(@cart) %>")

+ 1
- 1
app/views/store/index.html.erb View File

@@ -11,7 +11,7 @@
<%= sanitize(product.description) %> <%= sanitize(product.description) %>
<div class="price_line"> <div class="price_line">
<span class="price"><%= number_to_currency(product.price) %></span> <span class="price"><%= number_to_currency(product.price) %></span>
<%= button_to 'Add To Cart', line_items_path(product_id: product) %>
<%= button_to 'Add To Cart', line_items_path(product_id: product), remote: true %>
</div> </div>
</div> </div>
<% end %> <% end %>


Loading…
Cancel
Save