Commit 5a34ad79 by Tran Hoang Viet

VietTH: Hotfix fissue truncate category title

parent 9b8cf531
class CategoriesController < ApplicationController class CategoriesController < ApplicationController
before_action :set_category, only: [:show] before_action :set_category, only: [:show]
before_action :add_breadcrumb_home
def show def show
@products = @category.products.page(params[:page]) @products = @category.products.page(params[:page])
add_breadcrumb(@category.decorate.title)
end end
private private
......
...@@ -33,6 +33,7 @@ class ProductsController < ApplicationController ...@@ -33,6 +33,7 @@ class ProductsController < ApplicationController
def search def search
query = params[:query].present? ? {title: params[:query]} : '*' query = params[:query].present? ? {title: params[:query]} : '*'
@products = Product.search(query, page: params[:page]) @products = Product.search(query, page: params[:page])
add_breadcrumb('Search result')
end end
private private
......
...@@ -16,4 +16,8 @@ class ProductDecorator < Draper::Decorator ...@@ -16,4 +16,8 @@ class ProductDecorator < Draper::Decorator
def image_lg_url def image_lg_url
object.amazon? ? object.image_lg_url : object.image.large.url object.amazon? ? object.image_lg_url : object.image.large.url
end end
def short_title
return object.title.truncate(Settings.limit_length_category_title, separator: ' ')
end
end end
\ No newline at end of file
...@@ -17,5 +17,5 @@ class Product < ActiveRecord::Base ...@@ -17,5 +17,5 @@ class Product < ActiveRecord::Base
mount_uploader :image, ImageUploader mount_uploader :image, ImageUploader
solr_options per_page: 2, fields: [:id, :title] solr_options per_page: 5, fields: [:id, :title]
end end
- products.each do |product| - products.each do |product|
.product-item.col-md-4.text-center .product-item.col-md-4.text-center
.product-title .product-title
= link_to product.title, product = link_to product.decorate.short_title, product
.product-image.img-thumbnail .product-image.img-thumbnail
= image_tag product.decorate.image_md_url = image_tag product.decorate.image_md_url
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
%img{src: product.decorate.image_sm_url} %img{src: product.decorate.image_sm_url}
.col-md-9 .col-md-9
.product-title .product-title
= link_to product.title, product_path(product) = link_to product.decorate.short_title, product_path(product)
- if local_assigns.has_key?(:show_price) && show_price.present? - if local_assigns.has_key?(:show_price) && show_price.present?
.col-md-2 .col-md-2
.product-price .product-price
......
...@@ -2,6 +2,7 @@ defaults: &defaults ...@@ -2,6 +2,7 @@ defaults: &defaults
limit_category: 5 limit_category: 5
limit_product_recommended: 6 limit_product_recommended: 6
limit_product_newest: 4 limit_product_newest: 4
limit_length_category_title: 50
development: development:
<<: *defaults <<: *defaults
......
...@@ -46,12 +46,12 @@ ActiveRecord::Schema.define(version: 20150708092744) do ...@@ -46,12 +46,12 @@ ActiveRecord::Schema.define(version: 20150708092744) do
t.datetime "created_at", null: false t.datetime "created_at", null: false
t.datetime "updated_at", null: false t.datetime "updated_at", null: false
t.string "asin", limit: 255 t.string "asin", limit: 255
t.string "title", limit: 255 t.string "title", limit: 255, null: false
t.string "image_lg_url", limit: 255 t.string "image_lg_url", limit: 255
t.string "image_md_url", limit: 255 t.string "image_md_url", limit: 255
t.string "image_sm_url", limit: 255 t.string "image_sm_url", limit: 255
t.decimal "price", precision: 10, default: 0 t.decimal "price", precision: 10, default: 0
t.integer "category_id", limit: 4 t.integer "category_id", limit: 4, null: false
t.integer "product_type", limit: 4, default: 0 t.integer "product_type", limit: 4, default: 0
t.string "image", limit: 255 t.string "image", limit: 255
t.integer "user_id", limit: 4 t.integer "user_id", limit: 4
......
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