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
ceb74a0c
Commit
ceb74a0c
authored
Jul 15, 2015
by
Tran Hoang Viet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
VietTH: Create new product with new attribute :stock
parent
d95632a4
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
28 additions
and
3 deletions
+28
-3
app/assets/stylesheets/cart.css.scss
+2
-0
app/assets/stylesheets/layout.css.scss
+5
-0
app/controllers/products_controller.rb
+2
-2
app/models/product.rb
+1
-0
app/views/products/new.html.haml
+18
-1
No files found.
app/assets/stylesheets/cart.css.scss
View file @
ceb74a0c
...
...
@@ -18,6 +18,8 @@
color
:
blue
;
}
}
}
.input-group.spinner
{
.input-group-addon
{
padding
:
7px
12px
;
}
...
...
app/assets/stylesheets/layout.css.scss
View file @
ceb74a0c
...
...
@@ -132,4 +132,8 @@ footer{
border-bottom
:
0
!
important
;
border-left
:
0
!
important
;
border-right
:
0
!
important
;
}
.text-left
{
text-align
:
left
!
important
;
}
\ No newline at end of file
app/controllers/products_controller.rb
View file @
ceb74a0c
class
ProductsController
<
ApplicationController
before_action
:set_product
,
only:
[
:show
,
:add_cart
]
before_action
:set_categories
,
only:
[
:new
]
before_action
:set_categories
,
only:
[
:new
,
:create
]
before_action
:add_breadcrumb_home
before_action
:authenticate_user!
,
only:
[
:new
,
:create
,
:add_cart
]
...
...
@@ -48,7 +48,7 @@ class ProductsController < ApplicationController
end
def
product_params
params
.
require
(
:product
).
permit
(
:title
,
:price
,
:category_id
,
:image
)
params
.
require
(
:product
).
permit
(
:title
,
:price
,
:category_id
,
:image
,
:stock
)
end
def
cart_service
...
...
app/models/product.rb
View file @
ceb74a0c
...
...
@@ -12,6 +12,7 @@ class Product < ActiveRecord::Base
# validates
validates
:title
,
presence:
true
,
length:
{
maximum:
255
}
validates
:category
,
presence:
true
validates
:stock
,
presence:
true
,
numericality:
{
greater_than:
0
}
enum
product_type:
%i(system amazon)
...
...
app/views/products/new.html.haml
View file @
ceb74a0c
...
...
@@ -8,7 +8,24 @@
.form-group
=
f
.
label
:price
,
class:
'col-sm-2 control-label'
.col-sm-4
=
f
.
text_field
:price
,
class:
'form-control'
.customize-spinner.input-group.spinner
{
"data-trigger"
=>
"spinner"
}
=
f
.
text_field
:price
,
class:
'form-control text-left'
,
data:
{
min:
0
,
step:
1
}
.input-group-addon
%a
.spin-up
{
"data-spin"
=>
"up"
,
href:
"javascript:;"
}
%i
.fa.fa-sort-up
%a
.spin-down
{
"data-spin"
=>
"down"
,
href:
"javascript:;"
}
%i
.fa.fa-sort-down
.form-group
=
f
.
label
:stock
,
'Stock*'
,
class:
'col-sm-2 control-label'
.col-sm-4
.customize-spinner.input-group.spinner
{
"data-trigger"
=>
"spinner"
}
=
f
.
text_field
:stock
,
class:
'form-control text-left'
,
data:
{
min:
1
,
step:
1
}
.input-group-addon
%a
.spin-up
{
"data-spin"
=>
"up"
,
href:
"javascript:;"
}
%i
.fa.fa-sort-up
%a
.spin-down
{
"data-spin"
=>
"down"
,
href:
"javascript:;"
}
%i
.fa.fa-sort-down
.form-group
=
f
.
label
:category
,
class:
'col-sm-2 control-label'
...
...
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