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
55625ba6
Commit
55625ba6
authored
Oct 24, 2013
by
hades
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
card: insert card to db
parent
1a8d06d0
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
57 additions
and
2 deletions
+57
-2
venshop_app/app/controllers/cards_controller.rb
+21
-0
venshop_app/app/models/my_card.rb
+2
-0
venshop_app/app/views/cards/confirm_checkout.html.erb
+1
-1
venshop_app/db/migrate/20131024162951_create_my_cards.rb
+15
-0
venshop_app/db/schema.rb
+13
-1
venshop_app/spec/models/my_card_spec.rb
+5
-0
No files found.
venshop_app/app/controllers/cards_controller.rb
View file @
55625ba6
...
@@ -117,6 +117,27 @@ class CardsController < ApplicationController
...
@@ -117,6 +117,27 @@ class CardsController < ApplicationController
redirect_to
cards_path
redirect_to
cards_path
end
end
if
request
.
post?
if
request
.
post?
customer_info
=
@card_infos
[
:customer_info
]
card_items
=
@card_infos
[
:card_items
]
xml_data
=
'<?xml version="1.0"?>'
;
xml_data
+=
'<root>'
total
=
0
card_items
.
each
do
|
card_item
|
product
=
Product
.
find
(
card_item
[
:product_id
])
total
+=
product
.
price
xml_data
+=
'<item product_id="'
+
card_item
[
:product_id
].
to_s
+
'" quantity="'
+
card_item
[
:quantity
].
to_s
+
'" price="'
+
product
.
price
.
to_s
+
'" currency="'
+
product
.
price_currency
+
'" />'
end
xml_data
+=
'<total>'
+
total
.
to_s
+
'</total>'
xml_data
+=
'</root>'
MyCard
.
create!
(
full_name:
customer_info
[
:full_name
],
email:
customer_info
[
:email
],
phone:
customer_info
[
:phone
],
address:
customer_info
[
:address
],
note:
customer_info
[
:note
],
items:
xml_data
)
session
[
:SHOPPING_CARD_SESSION_NAME
]
=
nil
redirect_to
url_for
(
action:
'thankyou'
)
redirect_to
url_for
(
action:
'thankyou'
)
end
end
end
end
...
...
venshop_app/app/models/my_card.rb
0 → 100644
View file @
55625ba6
class
MyCard
<
ActiveRecord
::
Base
end
venshop_app/app/views/cards/confirm_checkout.html.erb
View file @
55625ba6
...
@@ -31,7 +31,7 @@
...
@@ -31,7 +31,7 @@
<%=
form_tag
do
%>
<%=
form_tag
do
%>
<div
class=
"text-center"
>
<div
class=
"text-center"
>
The information above
The information above
<a
href=
"
<%=
url_for
(
action:
'checkout'
)
%>
"
class=
"btn btn-default"
>
Incorrect,
click here
</a>
<a
href=
"
<%=
url_for
(
action:
'checkout'
)
%>
"
class=
"btn btn-default"
>
Incorrect,
edit
</a>
<%=
submit_tag
"Correct, click here"
,
class:
'btn btn-primary btn-submit'
%>
<%=
submit_tag
"Correct, click here"
,
class:
'btn btn-primary btn-submit'
%>
</div>
</div>
<%
end
%>
<%
end
%>
...
...
venshop_app/db/migrate/20131024162951_create_my_cards.rb
0 → 100644
View file @
55625ba6
class
CreateMyCards
<
ActiveRecord
::
Migration
def
change
create_table
:my_cards
do
|
t
|
t
.
string
:full_name
t
.
string
:email
t
.
string
:phone
t
.
string
:address
t
.
text
:note
t
.
text
:items
t
.
integer
:user_id
t
.
timestamps
end
end
end
venshop_app/db/schema.rb
View file @
55625ba6
...
@@ -11,7 +11,19 @@
...
@@ -11,7 +11,19 @@
#
#
# It's strongly recommended that you check this file into your version control system.
# It's strongly recommended that you check this file into your version control system.
ActiveRecord
::
Schema
.
define
(
version:
20131023094033
)
do
ActiveRecord
::
Schema
.
define
(
version:
20131024162951
)
do
create_table
"my_cards"
,
force:
true
do
|
t
|
t
.
string
"full_name"
t
.
string
"email"
t
.
string
"phone"
t
.
string
"address"
t
.
text
"note"
t
.
text
"items"
t
.
integer
"user_id"
t
.
datetime
"created_at"
t
.
datetime
"updated_at"
end
create_table
"product_categories"
,
force:
true
do
|
t
|
create_table
"product_categories"
,
force:
true
do
|
t
|
t
.
string
"name"
t
.
string
"name"
...
...
venshop_app/spec/models/my_card_spec.rb
0 → 100644
View file @
55625ba6
require
'spec_helper'
describe
MyCard
do
pending
"add some examples to (or delete)
#{
__FILE__
}
"
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