Commit d570482e by Tran Hoang Viet

VietTH: Implement show category detail

parent 8366883a
......@@ -66,4 +66,7 @@ gem 'carrierwave', '~> 0.10.0'
gem 'mini_magick', '~> 3.8.1'
# Background job
gem 'sidekiq', '~> 3.4.1'
\ No newline at end of file
gem 'sidekiq', '~> 3.4.1'
# pagination
gem 'kaminari', '~> 0.16.3'
\ No newline at end of file
......@@ -108,6 +108,9 @@ GEM
railties (>= 4.2.0)
thor (>= 0.14, < 2.0)
json (1.8.3)
kaminari (0.16.3)
actionpack (>= 3.0.0)
activesupport (>= 3.0.0)
kgio (2.9.3)
launchy (2.4.3)
addressable (~> 2.3)
......@@ -249,6 +252,7 @@ DEPENDENCIES
haml-rails (~> 0.9)
jbuilder (~> 2.0)
jquery-rails
kaminari (~> 0.16.3)
letter_opener (~> 1.4.1)
mini_magick (~> 3.8.1)
mysql2
......@@ -266,6 +270,3 @@ DEPENDENCIES
unicorn
vacuum (~> 1.3.0)
web-console (~> 2.0)
BUNDLED WITH
1.10.5
class CategoriesController < ApplicationController
before_action :set_category, only: [:show]
def show
@products = @category.products.page(params[:page])
end
private
def set_category
@category = Category.find_by(id: params[:id])
end
end
\ No newline at end of file
= render products
= render products, show_price: true
%h3.title
= @category.decorate.title
.module
#category-items.products-list-detail
= render @products
.pagination
= paginate @products
\ No newline at end of file
......@@ -5,7 +5,8 @@
.col-md-9
.product-title
= link_to product.title, product_path(product)
.col-md-2
.product-price
Price:
= product.decorate.price
\ No newline at end of file
- if local_assigns.has_key?(:show_price) && show_price.present?
.col-md-2
.product-price
Price:
= product.decorate.price
\ No newline at end of file
Kaminari.configure do |config|
config.default_per_page = 5
# config.max_per_page = nil
# config.window = 4
# config.outer_window = 0
# config.left = 0
# config.right = 0
# config.page_method_name = :page
# config.param_name = :page
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