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
huanvl
venshop
Commits
61d967f4
Commit
61d967f4
authored
Oct 25, 2013
by
vulehuan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add new product form
parent
7eca9aae
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
66 additions
and
5 deletions
+66
-5
venshop_app/app/controllers/products_controller.rb
+15
-0
venshop_app/app/views/products/_fields.html.erb
+32
-0
venshop_app/app/views/products/new.html.erb
+12
-0
venshop_app/app/views/shared/_error_messages.html.erb
+3
-3
venshop_app/app/views/users/_fields.html.erb
+2
-2
venshop_app/db/migrate/20131023094033_create_products.rb
+1
-0
venshop_app/db/schema.rb
+1
-0
No files found.
venshop_app/app/controllers/products_controller.rb
View file @
61d967f4
...
@@ -17,9 +17,24 @@ class ProductsController < ApplicationController
...
@@ -17,9 +17,24 @@ class ProductsController < ApplicationController
end
end
def
new
def
new
add_breadcrumb
"Add new product"
,
:new_product_path
@product
=
Product
.
new
@product
=
Product
.
new
end
end
def
user_items
def
user_items
end
end
private
def
product_params
params
.
require
(
:product
).
permit
(
:name
,
:description
,
:headline
,
:availability
,
:code
,
:condition
,
:image_small
,
:image_medium
,
:price_currency
,
:price
)
end
# Before filters
def
signed_in_user
unless
signed_in?
store_location
redirect_to
signin_url
,
notice:
"Please sign in."
end
end
end
end
venshop_app/app/views/products/_fields.html.erb
0 → 100644
View file @
61d967f4
<%=
render
'shared/error_messages'
,
entity:
@product
%>
<%=
f
.
label
:name
%>
<%=
f
.
text_field
:name
,
class:
"form-control"
%>
<%=
f
.
label
:description
%>
<%=
f
.
text_area
:description
,
class:
"form-control"
%>
<%=
f
.
label
:headline
%>
<%=
f
.
text_field
:headline
,
class:
"form-control"
%>
<%=
f
.
label
:availability
%>
<%=
f
.
text_field
:availability
,
class:
"form-control"
%>
<%=
f
.
label
:code
%>
<%=
f
.
text_field
:code
,
class:
"form-control"
%>
<%=
f
.
label
:condition
%>
<%=
f
.
text_field
:condition
,
class:
"form-control"
%>
<%=
f
.
label
:image_small
%>
<%=
f
.
text_field
:image_small
,
class:
"form-control"
%>
<%=
f
.
label
:image_medium
%>
<%=
f
.
text_field
:image_medium
,
class:
"form-control"
%>
<%=
f
.
label
:price_currency
%>
<%=
f
.
text_field
:price_currency
,
class:
"form-control"
%>
<%=
f
.
label
:price
%>
<%=
f
.
text_field
:price
,
class:
"form-control"
%>
\ No newline at end of file
venshop_app/app/views/products/new.html.erb
0 → 100644
View file @
61d967f4
<%
provide
(
:title
,
'Add new product'
)
%>
<div
class=
"body-box"
>
<h2
class=
"sprite-2"
>
Add new product
<span
class=
"sprite-2"
></span></h2>
<div
class=
"text-justify"
>
<%=
form_for
(
@product
)
do
|
f
|
%>
<%=
render
'fields'
,
f
:f
%>
<%=
f
.
submit
"Submit"
,
class:
"btn btn-large btn-primary btn-submit"
%>
<%
end
%>
</div>
</div>
\ No newline at end of file
venshop_app/app/views/shared/_error_messages.html.erb
View file @
61d967f4
<%
if
@user
.
errors
.
any?
%>
<%
if
entity
.
errors
.
any?
%>
<div
id=
"error_explanation"
>
<div
id=
"error_explanation"
>
<div
class=
"alert alert-error"
>
<div
class=
"alert alert-error"
>
The form contains
<%=
pluralize
(
@user
.
errors
.
count
,
"error"
)
%>
.
The form contains
<%=
pluralize
(
entity
.
errors
.
count
,
"error"
)
%>
.
<ul>
<ul>
<%
@user
.
errors
.
full_messages
.
each
do
|
msg
|
%>
<%
entity
.
errors
.
full_messages
.
each
do
|
msg
|
%>
<li>
<%=
msg
%>
</li>
<li>
<%=
msg
%>
</li>
<%
end
%>
<%
end
%>
</ul>
</ul>
...
...
venshop_app/app/views/users/_fields.html.erb
View file @
61d967f4
<%=
render
'shared/error_messages'
%>
<%=
render
'shared/error_messages'
,
entity:
@user
%>
<%=
f
.
label
:name
%>
<%=
f
.
label
:name
%>
<%=
f
.
text_field
:name
,
class:
"form-control"
%>
<%=
f
.
text_field
:name
,
class:
"form-control"
%>
<%=
f
.
label
:email
%>
<%=
f
.
label
:email
%>
<%=
f
.
text_field
:email
,
class:
"form-control"
,
class:
"form-control"
%>
<%=
f
.
text_field
:email
,
class:
"form-control"
%>
<%=
f
.
label
:password
%>
<%=
f
.
label
:password
%>
<%=
f
.
password_field
:password
,
class:
"form-control"
%>
<%=
f
.
password_field
:password
,
class:
"form-control"
%>
...
...
venshop_app/db/migrate/20131023094033_create_products.rb
View file @
61d967f4
...
@@ -14,6 +14,7 @@ class CreateProducts < ActiveRecord::Migration
...
@@ -14,6 +14,7 @@ class CreateProducts < ActiveRecord::Migration
t
.
string
:price_currency
t
.
string
:price_currency
t
.
decimal
:price
t
.
decimal
:price
t
.
integer
:product_category_id
t
.
integer
:product_category_id
t
.
integer
:user_id
t
.
timestamps
t
.
timestamps
end
end
...
...
venshop_app/db/schema.rb
View file @
61d967f4
...
@@ -47,6 +47,7 @@ ActiveRecord::Schema.define(version: 20131024162951) do
...
@@ -47,6 +47,7 @@ ActiveRecord::Schema.define(version: 20131024162951) do
t
.
string
"price_currency"
t
.
string
"price_currency"
t
.
decimal
"price"
,
precision:
10
,
scale:
0
t
.
decimal
"price"
,
precision:
10
,
scale:
0
t
.
integer
"product_category_id"
t
.
integer
"product_category_id"
t
.
integer
"user_id"
t
.
datetime
"created_at"
t
.
datetime
"created_at"
t
.
datetime
"updated_at"
t
.
datetime
"updated_at"
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