Commit cb1b8ed4 by Dao Minh Nhut

show product

parent 610b05fc
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://coffeescript.org/
// Place all the styles related to the static_pages controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
body {
padding-bottom: 40px;
padding-top: 60px;
}
\ No newline at end of file
...@@ -2,16 +2,18 @@ class ProductsController < ApplicationController ...@@ -2,16 +2,18 @@ class ProductsController < ApplicationController
#before_filter :signed_in_user, only: [:create, :destroy] #before_filter :signed_in_user, only: [:create, :destroy]
#before_filter :correct_user, only: :destroy #before_filter :correct_user, only: :destroy
#def show
#@item = Product.find(params[:id])
#end
def index def index
@item = Product.all @products = Product.paginate(page: params[:page])
@categories = Category.all #@categories = Category.all
#@items = Product.all.select do |i| #@items = Product.all.select do |i|
#i.category==params[:id] #i.category==params[:id]
#end #end
end end
def show
@product = Product.find(params[:id])
end
def new def new
@item= Product.new @item= Product.new
render layout: "another_layout" render layout: "another_layout"
......
class StaticPagesController < ApplicationController
end
module StaticPagesHelper
end
<li><%= link_to category.name, category_path(category) %></li>
\ No newline at end of file
...@@ -4,13 +4,17 @@ ...@@ -4,13 +4,17 @@
<div class="thumbnail"> <div class="thumbnail">
<%= image_tag product.image %> <%= image_tag product.image %>
<div class="caption"> <div class="caption">
<h4><%= truncate(product.name, :length => 25, :omission => '...') %></h4> <div style="height: 40px">
<h4><%= truncate(product.name, :length => 30, :omission => '...') %></h4>
</div>
<p><%= product.price %> $</p> <p><%= product.price %> $</p>
<a class="btn btn-primary" href="#">View</a> <%= link_to 'View', products_path(product_id: @product), class: 'btn btn-primary' %>
<a class="btn btn-success" href="#">Add to Cart</a> <a class="btn btn-success" href="#">Add to Cart</a>
</div> </div>
</div> </div>
</li> </li>
<% end %> <% end %>
</ul> </ul>
<%= will_paginate @products%> <div align="center">
\ No newline at end of file <%= will_paginate @products%>
</div>
\ No newline at end of file
<ul class="thumbnails">
<% @products.each do |product| %>
<li class="span3">
<div class="thumbnail">
<%= image_tag product.image %>
<div class="caption">
<div style="height: 40px">
<h4><%= truncate(product.name, :length => 30, :omission => '...') %></h4>
</div>
<p><%= product.price/100.000 %> $</p>
<%= link_to 'View', {controller: "products", action: "show", id: product.id} , class: 'btn btn-primary'%>
<a class="btn btn-success" href="#">Add to Cart</a>
</div>
</div>
</li>
<% end %>
</ul>
<div align="center">
<%= will_paginate @products%>
</div>
\ No newline at end of file
<div class="span8 center"> <div class="span9">
<h3>Name: </h3><%= @product.name%><br><br> <div class="row">
</div><!--/span-->
\ No newline at end of file <div class="span5">
<div id="items-carousel" class="carousel slide mbottom0">
<div class="carousel-inner">
<div class="active item">
<%= image_tag @product.image %>
</div>
</div>
</div>
</div>
<div class="span4">
<h4><%= @product.name %></h4>
<p><%= @product.description %></p>
<h4><%= @product.price/100.000 %> $</h4>
<label>
<p>Quanity:</p> &nbsp;<input type="text" id="quantity" name="quantity" value="1" class="span1" />
</label>
<button class="btn btn-primary">Add to Chart</button>
</div>
</div>
</div>
\ No newline at end of file
...@@ -5,13 +5,16 @@ VenShop::Application.routes.draw do ...@@ -5,13 +5,16 @@ VenShop::Application.routes.draw do
get 'cart/new' get 'cart/new'
devise_for :users devise_for :users
#root to: 'home#index' root 'products#index'
get 'home/index'
get 'categories/new' get 'categories/new'
get 'categories/category'
get 'products/show' get 'products/show'
get '/help', to: 'static_pages#help' get '/help' => 'static_pages#help'
get '/about', to: 'static_pages#about' get '/about' => 'static_pages#about'
get '/contact', to: 'static_pages#contact' get '/contact' => 'static_pages#contact'
resources :product, only: [:show]
resources :products
resources :line_items, only: [:show]
# match '/categories/:id', to: 'categories#show' # match '/categories/:id', to: 'categories#show'
# match '/items/:id', to: 'items#show' # match '/items/:id', to: 'items#show'
# match '/user/add_to_cart/:id', to: 'users#add_to_cart' # match '/user/add_to_cart/:id', to: 'users#add_to_cart'
......
require 'test_helper'
class StaticPagesControllerTest < ActionController::TestCase
# test "the truth" do
# assert true
# end
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment