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
b04d8363
Commit
b04d8363
authored
Jul 23, 2015
by
Tran Hoang Viet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
VietTH: Implement fragment cache for categories
parent
339cfb67
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
15 additions
and
3 deletions
+15
-3
app/helpers/categories_helper.rb
+8
-0
app/views/layouts/_sidebar.html.haml
+4
-2
app/views/products/new.html.haml
+1
-0
app/views/search/_form_search.html.haml
+1
-0
config/environments/development.rb
+1
-1
No files found.
app/helpers/categories_helper.rb
0 → 100644
View file @
b04d8363
module
CategoriesHelper
def
cache_key_for_categories
count
=
Category
.
all
.
size
max_updated_at
=
Category
.
maximum
(
:updated_at
).
try
(
:utc
).
try
(
:to_s
,
:number
)
"products/all-
#{
count
}
-
#{
max_updated_at
}
"
end
end
\ No newline at end of file
app/views/layouts/_sidebar.html.haml
View file @
b04d8363
%h3
.title
Category
%ul
.nav.nav-sidebar
-
cache
(
cache_key_for_categories
)
do
%h3
.title
Category
%ul
.nav.nav-sidebar
=
render
partial:
'/categories/category'
,
collection:
Category
.
limit
(
Settings
.
limit_category
).
select
(
Category
::
JSON_DEFAULT
)
\ No newline at end of file
app/views/products/new.html.haml
View file @
b04d8363
...
...
@@ -30,6 +30,7 @@
.form-group
=
f
.
label
:category
,
class:
'col-sm-2 control-label'
.col-sm-4
-
cache
(
"product-new-
#{
cache_key_for_categories
}
"
)
do
=
f
.
collection_select
:category_id
,
@categories
.
decorate
,
:id
,
:title
,
{},
class:
'form-control'
.form-group
...
...
app/views/search/_form_search.html.haml
View file @
b04d8363
...
...
@@ -7,6 +7,7 @@
.form-group
=
label
:query
,
'Category: '
,
class:
'col-sm-2 control-label'
.col-sm-5
-
cache
(
"search-
#{
cache_key_for_categories
}
"
)
do
=
select_tag
:category
,
options_from_collection_for_select
(
@categories
.
decorate
,
:id
,
:title
,
params
[
:category
]),
{
include_blank:
'-- Select category --'
,
class:
'form-control chosen-select'
,
multiple:
true
}
.form-group
=
label
:query
,
'Product price: '
,
class:
'col-sm-2 control-label'
...
...
config/environments/development.rb
View file @
b04d8363
...
...
@@ -11,7 +11,7 @@ Rails.application.configure do
# Show full error reports and disable caching.
config
.
consider_all_requests_local
=
true
config
.
action_controller
.
perform_caching
=
fals
e
config
.
action_controller
.
perform_caching
=
tru
e
# Don't care if the mailer can't send.
config
.
action_mailer
.
raise_delivery_errors
=
false
...
...
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