Skip to content

Commit

Permalink
Totally forgot where I am
Browse files Browse the repository at this point in the history
  • Loading branch information
jonpaul committed Jun 6, 2011
1 parent 9d006a6 commit 11418de
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 23 deletions.
4 changes: 2 additions & 2 deletions app/controllers/line_items_controller.rb
Expand Up @@ -46,9 +46,9 @@ def create

respond_to do |format|
if @line_item.save
format.html { redirect_to(@line_item.cart,
:notice => 'Line item was successfully created.') }
format.html { redirect_to(store_url) }
format.xml { render :xml => @line_item, :status => :created, :location => @line_item }
format.js { @current_item = @line_item }
else
format.html { render :action => "new" }
format.xml { render :xml => @line_item.errors, :status => :unprocessable_entity }
Expand Down
1 change: 1 addition & 0 deletions app/controllers/store_controller.rb
@@ -1,6 +1,7 @@
class StoreController < ApplicationController
def index
@products = Product.all
@cart = current_cart
end

end
20 changes: 1 addition & 19 deletions app/views/carts/show.html.erb
@@ -1,19 +1 @@
<div class="cart_title">Your Cart</div>
<table>
<% @cart.line_items.each do |item| %>
<tr>
<td><%= item.quantity %>&times;</td>
<td><%= item.product.title %></td>
<td class="item_price"><%= number_to_currency(item.total_price) %></td>
</tr>
<% end %>

<tr class="total_line">
<td colspan="2">Total</td>
<td class="total_cell"><%= number_to_currency(@cart.total_price) %></td>
</tr>

</table>

<%= button_to 'Empty cart', @cart, :method => :delete,
:confirm => 'Are you sure?' %>
<%= render @cart %>
3 changes: 3 additions & 0 deletions app/views/layouts/application.html.erb
Expand Up @@ -14,6 +14,9 @@
</div>
<div id="columns">
<div id="side">
<div id="cart">
<%= render @cart %>
</div>
<ul>
<li><a href="/">Home</a></li>
<li><a href="/faq">Questions</a></li>
Expand Down
2 changes: 1 addition & 1 deletion app/views/store/index.html.erb
Expand Up @@ -12,7 +12,7 @@
<%= sanitize product.description %>
<div class="price_line">
<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>
<% end %>
17 changes: 16 additions & 1 deletion public/stylesheets/depot.css
Expand Up @@ -175,4 +175,19 @@
font-weight: bold;
border-top: 1px solid #595;
}
/* END:cartmain */
/* END:cartmain */

/* START:cartside */
/* Styles for the cart in the sidebar */

#cart, #cart table {
font-size: smaller;
color: white;
}

#cart table {
border-top: 1px dotted #595;
border-bottom: 1px dotted #595;
margin-bottom: 10px;
}
/* END:cartside */

0 comments on commit 11418de

Please sign in to comment.