Skip to content

Instantly share code, notes, and snippets.

@rocodev-tech
rocodev-tech / routes.rb
Created June 12, 2014 21:39
config/routes.rb
resources :products do
member do
post :add_to_cart
end
end
@rocodev-tech
rocodev-tech / show.html.erb
Created June 12, 2014 21:37
app/views/product/show.html.erb
<div> 數量 : <%= render_product_quantity(@product) %> </div>
<div class="product-price"> $ <%= render_product_price(@product) %> </div>
<div class="pull-right">
<%= link_to("加入購物車", add_to_cart_product_path(@product) , :method => :post , :class => "btn btn-primary btn-lg btn-danger") %>
</div>
@rocodev-tech
rocodev-tech / _navbar.html.erb
Created June 12, 2014 21:16
app/views/common/_navbar.html.erb
<ul class="nav navbar-nav navbar-right">
<li>
<%= link_to "#" do %>
購物車 <i class="glyphicon glyphicon-shopping-cart"> </i> (0)
<% end %>
</li>
<% if !current_user %>
<li> <%= link_to("登入", new_user_session_path) %> </li>