Skip to content

Commit

Permalink
11.1
Browse files Browse the repository at this point in the history
  • Loading branch information
healthkxy committed Mar 6, 2012
1 parent 316c82e commit 9f30785
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 26 deletions.
19 changes: 19 additions & 0 deletions app/assets/stylesheets/application.css.scss
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,25 @@
width: 13em;
background: #141;

form, div {
display: inline;
}

input {
font-size: small;
}

#cart {
font-size: smaller;
color: white;

table {
border-top: 1px dotted #595;
border-bottom: 1px dotted #595;
margin-bottom: 10px;
}
}

ul {
padding: 0;

Expand Down
2 changes: 1 addition & 1 deletion app/assets/stylesheets/carts.css.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/

.carts {
.carts, #side #cart {
.cart_title {
font: 120% bold;
}
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/line_items_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def create

respond_to do |format|
if @line_item.save
format.html { redirect_to @line_item.cart }
format.html { redirect_to store_url }
format.json { render json: @line_item, status: :created, location: @line_item }
else
format.html { render action: "new" }
Expand Down
1 change: 1 addition & 0 deletions app/controllers/store_controller.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
class StoreController < ApplicationController
def index
@products = Product.order(:title)
@cart = current_cart
end
end
13 changes: 13 additions & 0 deletions app/views/carts/_cart.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

<div class="cart_title">Your Cart</div>
<table>
<%= render(cart.line_items) %>
<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?' %>
25 changes: 1 addition & 24 deletions app/views/carts/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,4 @@
<p id="notice"><%= notice %></p>
<% end %>

<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?' %>

<!--
<%= link_to 'Edit', edit_cart_path(@cart) %> |
<%= link_to 'Back', carts_path %>
-->
<%= render @cart %>
4 changes: 4 additions & 0 deletions app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
</div>
<div id="columns">
<div id="side">
<div id="cart">
<%= render @cart %>
</div>

<ul>
<li><a href="http://www....">Home</a></li>
<li><a href="http://www..../faq">Questions</a></li>
Expand Down
5 changes: 5 additions & 0 deletions app/views/line_items/_line_item.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<tr>
<td><%= line_item.quantity %>&times;</td>
<td><%= line_item.product.title %></td>
<td class="item_price"><%= number_to_currency(line_item.total_price) %></td>
</tr>

0 comments on commit 9f30785

Please sign in to comment.