Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
V
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
0
Merge Requests
0
Wiki
Wiki
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Nguyen Quoc Kien
venshop
Commits
6e7cea70
Commit
6e7cea70
authored
Aug 05, 2015
by
Nguyen Quoc Kien
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Review code: Move find_product() to application_controller
parent
5fca702f
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
9 additions
and
14 deletions
+9
-14
app/controllers/admin/products_controller.rb
+0
-4
app/controllers/application_controller.rb
+9
-0
app/controllers/products_controller.rb
+0
-10
No files found.
app/controllers/admin/products_controller.rb
View file @
6e7cea70
...
...
@@ -43,10 +43,6 @@ class Admin::ProductsController < ApplicationController
private
def
find_product
@product
=
Product
.
find
(
params
[
:id
])
end
def
product_params
params
.
require
(
:product
).
permit
(
:category_id
,
:name
,
:price
,
:image
,
:description
)
end
...
...
app/controllers/application_controller.rb
View file @
6e7cea70
...
...
@@ -41,4 +41,13 @@ class ApplicationController < ActionController::Base
def
is_number?
string
true
if
Float
(
string
)
rescue
false
end
def
find_product
if
params
[
:id
].
to_i
>
(
Product
.
count
+
1
)
redirect_to
error_path
else
@product
=
Product
.
find
(
params
[
:id
])
end
end
end
app/controllers/products_controller.rb
View file @
6e7cea70
...
...
@@ -11,14 +11,4 @@ class ProductsController < ApplicationController
@categories
=
Category
.
all
end
private
def
find_product
if
params
[
:id
].
to_i
>
(
Product
.
count
+
1
)
redirect_to
error_path
else
@product
=
Product
.
find
(
params
[
:id
])
end
end
end
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