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
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
Tan Phat Nguyen
venshop
Commits
c57a728d
Commit
c57a728d
authored
Nov 12, 2014
by
Tan Phat Nguyen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
layout show item fix, paging category max item 10
parent
6095a97a
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
13 additions
and
6 deletions
+13
-6
app/assets/stylesheets/custom.css.scss
+7
-2
app/controllers/admin/products_controller.rb
+1
-1
app/models/product.rb
+3
-3
app/views/admin/products/index.html.erb
+2
-0
No files found.
app/assets/stylesheets/custom.css.scss
View file @
c57a728d
...
...
@@ -44,8 +44,8 @@
}
.main
{
padding-right
:
40
px
;
padding-left
:
4
0px
;
padding-right
:
24
px
;
padding-left
:
8
0px
;
}
.main
.page-header
{
...
...
@@ -81,3 +81,7 @@ h2 {
.price-col
{
color
:
#b12704
;
}
.col-sm-3
{
width
:
20%
;
}
\ No newline at end of file
app/controllers/admin/products_controller.rb
View file @
c57a728d
...
...
@@ -2,7 +2,7 @@ class Admin::ProductsController < ApplicationController
before_action
:set_product
,
only:
[
:show
,
:edit
,
:update
,
:destroy
]
def
index
@products
=
Product
.
all
@products
=
Product
.
all
.
page
(
params
[
:page
])
end
def
new
...
...
app/models/product.rb
View file @
c57a728d
...
...
@@ -2,17 +2,17 @@ class Product < ActiveRecord::Base
belongs_to
:category
validates
:name
,
presence:
true
,
length:
{
maximum:
5
0
}
validates
:name
,
presence:
true
,
length:
{
maximum:
20
0
}
validates
:price
,
presence:
true
,
numericality:
true
,
format:
{
with:
/\A\d+(?:\.\d{0,2})?\z/
}
validates
:description
,
presence:
true
validate
:photo_size
scope
:newest
,
->
{
order
(
created_at: :desc
).
limit
(
4
)
}
scope
:newest
,
->
{
order
(
created_at: :desc
).
limit
(
5
)
}
mount_uploader
:photo
,
ImageUploader
paginates_per
8
paginates_per
10
private
...
...
app/views/admin/products/index.html.erb
View file @
c57a728d
...
...
@@ -12,5 +12,6 @@
</tr>
<%=
render
@products
%>
</table>
<%=
paginate
@products
%>
</div>
<%=
link_to
'New Product'
,
new_admin_product_path
,
class:
"btn btn-primary"
%>
\ No newline at end of file
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