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
26aab3c8
Commit
26aab3c8
authored
Jul 13, 2015
by
Tran Hoang Viet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
VietTH: Fix review code feature search
parent
5a3bd5d8
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
14 additions
and
9 deletions
+14
-9
app/controllers/application_controller.rb
+6
-0
app/controllers/categories_controller.rb
+2
-2
app/controllers/orders_controller.rb
+1
-1
app/controllers/products_controller.rb
+5
-6
No files found.
app/controllers/application_controller.rb
View file @
26aab3c8
class
ApplicationController
<
ActionController
::
Base
rescue_from
ActiveRecord
::
RecordNotFound
,
:with
=>
:record_not_found
layout
Proc
.
new
{
|
controller
|
controller
.
devise_controller?
?
'devise'
:
'application'
}
# Prevent CSRF attacks by raising an exception.
...
...
@@ -14,4 +15,8 @@ class ApplicationController < ActionController::Base
def
add_breadcrumb_home
add_breadcrumb
(
'Home'
,
root_path
)
end
def
record_not_found
redirect_to
(
root_path
,
alert:
"Resource not found"
)
end
end
\ No newline at end of file
app/controllers/categories_controller.rb
View file @
26aab3c8
...
...
@@ -7,8 +7,7 @@ class CategoriesController < ApplicationController
private
def
set_category
@category
=
Category
.
find_by
(
id:
params
[
:id
])
redirect_to
root_path
,
alert:
"Category not found"
if
@category
.
blank?
@category
=
Category
.
find
(
params
[
:id
])
end
end
\ No newline at end of file
app/controllers/orders_controller.rb
View file @
26aab3c8
...
...
@@ -10,7 +10,7 @@ class OrdersController < ApplicationController
def
create
if
order_service
.
create
(
order_params
)
clear_cart
redirect_to
root_path
redirect_to
(
root_path
,
notice:
'Checkout is successful.'
)
else
render
:index
end
...
...
app/controllers/products_controller.rb
View file @
26aab3c8
...
...
@@ -14,9 +14,9 @@ class ProductsController < ApplicationController
def
create
@product
=
Product
.
new
(
product_params
)
if
@product
.
save
redirect_to
root_path
redirect_to
(
root_path
)
else
render
:new
render
(
:new
)
end
end
...
...
@@ -26,8 +26,8 @@ class ProductsController < ApplicationController
end
def
add_cart
add_to_cart
@product
redirect_to
@product
add_to_cart
(
@product
)
redirect_to
(
@product
,
notice:
'Product is added to cart.'
)
end
def
search
...
...
@@ -37,8 +37,7 @@ class ProductsController < ApplicationController
private
def
set_product
@product
=
Product
.
find_by
(
id:
params
[
:id
])
redirect_to
root_path
,
alert:
"Product not found"
if
@product
.
blank?
@product
=
Product
.
find
(
params
[
:id
])
end
def
set_categories
...
...
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