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
d38dc405
Commit
d38dc405
authored
Jul 27, 2015
by
Nguyen Quoc Kien
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
first
parent
822f1eba
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
17 additions
and
6 deletions
+17
-6
app/controllers/carts_controller.rb
+3
-1
app/views/carts/edit.html.erb
+0
-3
app/views/products/_product.html.erb
+1
-1
db/migrate/20150727094602_add_phone_to_users.rb
+5
-0
db/migrate/20150727094623_add_address_to_users.rb
+5
-0
db/schema.rb
+3
-1
No files found.
app/controllers/carts_controller.rb
View file @
d38dc405
...
...
@@ -12,8 +12,10 @@ class CartsController < ApplicationController
def
update
@cart
=
Cart
.
find
(
session
[
:cart_id
])
#@user = User.find(@cart.user_id)
@user
=
User
.
find
(
@cart
.
user_id
)
@user
.
update
(
address:
params
[
'cart'
][
'address'
],
phone:
params
[
'cart'
][
'phone'
])
@cart
.
update
(
cart_params
)
@cart
.
update
(
status:
"checkout"
)
OrderNotifier
.
received
(
@cart
).
deliver
session
[
:cart_id
]
=
nil
respond_to
do
|
format
|
...
...
app/views/carts/edit.html.erb
View file @
d38dc405
...
...
@@ -16,9 +16,6 @@
<%=
f
.
label
:phone
%>
<%=
f
.
text_field
:phone
,
class:
'form-control'
%>
<%=
f
.
label
:status
%>
<%=
f
.
text_field
:status
,
class:
'form-control'
%>
<br>
<%=
f
.
submit
"Save changes"
,
class:
"btn btn-primary"
%>
<%
end
%>
...
...
app/views/products/_product.html.erb
View file @
d38dc405
...
...
@@ -6,7 +6,7 @@
<h3
title=
"
<%=
product
.
name
%>
"
>
<%=
truncate
(
product
.
name
,
length:
25
)
%>
</h3>
</div>
<p><b>
Price:
</b>
<%=
number_to_currency
(
product
.
price
/
100.000
)
%>
</p>
<p>
Quanlity:
<%=
text_field
_tag
:thing
,
type:
"number"
%>
<p>
Quanlity:
<%=
text_field
:number
,
class:
'form-control'
%>
<%=
button_to
"Add To cart"
,
cart_products_path
(
product_id:
product
),
:class
=>
"btn btn-primary"
,
:style
=>
"width: 100px"
%>
<br/>
<%=
link_to
"More Info"
,
product
,
:class
=>
"btn btn-default"
%>
</p>
</div>
...
...
db/migrate/20150727094602_add_phone_to_users.rb
0 → 100644
View file @
d38dc405
class
AddPhoneToUsers
<
ActiveRecord
::
Migration
def
change
add_column
:users
,
:phone
,
:string
end
end
db/migrate/20150727094623_add_address_to_users.rb
0 → 100644
View file @
d38dc405
class
AddAddressToUsers
<
ActiveRecord
::
Migration
def
change
add_column
:users
,
:address
,
:string
end
end
db/schema.rb
View file @
d38dc405
...
...
@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord
::
Schema
.
define
(
version:
2015072
4174931
)
do
ActiveRecord
::
Schema
.
define
(
version:
2015072
7094623
)
do
create_table
"cart_products"
,
force: :cascade
do
|
t
|
t
.
integer
"cart_id"
,
limit:
4
,
null:
false
...
...
@@ -68,6 +68,8 @@ ActiveRecord::Schema.define(version: 20150724174931) do
t
.
datetime
"created_at"
,
null:
false
t
.
datetime
"updated_at"
,
null:
false
t
.
string
"username"
,
limit:
255
t
.
string
"phone"
,
limit:
255
t
.
string
"address"
,
limit:
255
end
add_index
"users"
,
[
"email"
],
name:
"index_users_on_email"
,
unique:
true
,
using: :btree
...
...
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