Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
V
VietTH-VenShop
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
4
Merge Requests
4
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Tran Hoang Viet
VietTH-VenShop
Commits
5a34ad79
Commit
5a34ad79
authored
Jul 13, 2015
by
Tran Hoang Viet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
VietTH: Hotfix fissue truncate category title
parent
9b8cf531
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
14 additions
and
5 deletions
+14
-5
app/controllers/categories_controller.rb
+2
-0
app/controllers/products_controller.rb
+1
-0
app/decorators/product_decorator.rb
+5
-0
app/models/product.rb
+1
-1
app/views/categories/_recommended.html.haml
+1
-1
app/views/products/_product.html.haml
+1
-1
config/settings.yml
+1
-0
db/schema.rb
+2
-2
No files found.
app/controllers/categories_controller.rb
View file @
5a34ad79
class
CategoriesController
<
ApplicationController
before_action
:set_category
,
only:
[
:show
]
before_action
:add_breadcrumb_home
def
show
@products
=
@category
.
products
.
page
(
params
[
:page
])
add_breadcrumb
(
@category
.
decorate
.
title
)
end
private
...
...
app/controllers/products_controller.rb
View file @
5a34ad79
...
...
@@ -33,6 +33,7 @@ class ProductsController < ApplicationController
def
search
query
=
params
[
:query
].
present?
?
{
title:
params
[:
query
]}
:
'*'
@products
=
Product
.
search
(
query
,
page:
params
[
:page
])
add_breadcrumb
(
'Search result'
)
end
private
...
...
app/decorators/product_decorator.rb
View file @
5a34ad79
...
...
@@ -16,4 +16,8 @@ class ProductDecorator < Draper::Decorator
def
image_lg_url
object
.
amazon?
?
object
.
image_lg_url
:
object
.
image
.
large
.
url
end
def
short_title
return
object
.
title
.
truncate
(
Settings
.
limit_length_category_title
,
separator:
' '
)
end
end
\ No newline at end of file
app/models/product.rb
View file @
5a34ad79
...
...
@@ -17,5 +17,5 @@ class Product < ActiveRecord::Base
mount_uploader
:image
,
ImageUploader
solr_options
per_page:
2
,
fields:
[
:id
,
:title
]
solr_options
per_page:
5
,
fields:
[
:id
,
:title
]
end
app/views/categories/_recommended.html.haml
View file @
5a34ad79
-
products
.
each
do
|
product
|
.product-item.col-md-4.text-center
.product-title
=
link_to
product
.
title
,
product
=
link_to
product
.
decorate
.
short_
title
,
product
.product-image.img-thumbnail
=
image_tag
product
.
decorate
.
image_md_url
app/views/products/_product.html.haml
View file @
5a34ad79
...
...
@@ -4,7 +4,7 @@
%img
{
src:
product
.
decorate
.
image_sm_url
}
.col-md-9
.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?
.col-md-2
.product-price
...
...
config/settings.yml
View file @
5a34ad79
...
...
@@ -2,6 +2,7 @@ defaults: &defaults
limit_category
:
5
limit_product_recommended
:
6
limit_product_newest
:
4
limit_length_category_title
:
50
development
:
<<
:
*defaults
...
...
db/schema.rb
View file @
5a34ad79
...
...
@@ -46,12 +46,12 @@ ActiveRecord::Schema.define(version: 20150708092744) do
t
.
datetime
"created_at"
,
null:
false
t
.
datetime
"updated_at"
,
null:
false
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_md_url"
,
limit:
255
t
.
string
"image_sm_url"
,
limit:
255
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
.
string
"image"
,
limit:
255
t
.
integer
"user_id"
,
limit:
4
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment