beecart 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/Rakefile +34 -0
- data/app/assets/javascripts/cartbee/application.js +13 -0
- data/app/assets/stylesheets/cartbee/application.css +13 -0
- data/app/controllers/beecart/application_controller.rb +4 -0
- data/app/helpers/beecart/application_helper.rb +4 -0
- data/app/views/layouts/beecart/application.html.erb +14 -0
- data/config/routes.rb +2 -0
- data/lib/beecart/controllers/core_ext.rb +13 -0
- data/lib/beecart/engine.rb +5 -0
- data/lib/beecart/models/shopping_cart.rb +178 -0
- data/lib/beecart/version.rb +3 -0
- data/lib/beecart.rb +41 -0
- data/lib/tasks/cartbee_tasks.rake +4 -0
- data/test/cartbee_test.rb +7 -0
- data/test/dummy/README.rdoc +28 -0
- data/test/dummy/Rakefile +6 -0
- data/test/dummy/app/assets/javascripts/application.js +13 -0
- data/test/dummy/app/assets/stylesheets/application.css +27 -0
- data/test/dummy/app/controllers/application_controller.rb +5 -0
- data/test/dummy/app/controllers/carts_controller.rb +43 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/views/carts/index.html.erb +56 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/bin/bundle +3 -0
- data/test/dummy/bin/rails +4 -0
- data/test/dummy/bin/rake +4 -0
- data/test/dummy/config/application.rb +23 -0
- data/test/dummy/config/boot.rb +5 -0
- data/test/dummy/config/database.yml +25 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +29 -0
- data/test/dummy/config/environments/production.rb +80 -0
- data/test/dummy/config/environments/test.rb +36 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/beecart.rb +6 -0
- data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/test/dummy/config/initializers/inflections.rb +16 -0
- data/test/dummy/config/initializers/mime_types.rb +5 -0
- data/test/dummy/config/initializers/secret_token.rb +12 -0
- data/test/dummy/config/initializers/session_store.rb +3 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +23 -0
- data/test/dummy/config/routes.rb +9 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/log/development.log +0 -0
- data/test/dummy/public/404.html +58 -0
- data/test/dummy/public/422.html +58 -0
- data/test/dummy/public/500.html +57 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/integration/navigation_test.rb +10 -0
- data/test/test_helper.rb +15 -0
- metadata +161 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 2ccbd0ea9e12e035c4b114b5835be8983b384a2f
|
4
|
+
data.tar.gz: 14d64a85490ab46665a4962e2d9caf09db246019
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 28fff7170437a3712f2c443cd91f555430a92945b1a60ac5ce8783b551c009f2f54dbe0cbbb04137653bb676719555fde5a2edb053b4b529786031e25492633a
|
7
|
+
data.tar.gz: 25f67576819a2c8123944cc462ac583461f814e99525357d42eba34e594d540ac65f80df9e37c1a27c29a7bee295284456112e064a90dc53c007eae729218ac5
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2014 YOURNAME
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
begin
|
2
|
+
require 'bundler/setup'
|
3
|
+
rescue LoadError
|
4
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
5
|
+
end
|
6
|
+
|
7
|
+
require 'rdoc/task'
|
8
|
+
|
9
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
10
|
+
rdoc.rdoc_dir = 'rdoc'
|
11
|
+
rdoc.title = 'Cartbee'
|
12
|
+
rdoc.options << '--line-numbers'
|
13
|
+
rdoc.rdoc_files.include('README.rdoc')
|
14
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
15
|
+
end
|
16
|
+
|
17
|
+
APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
|
18
|
+
load 'rails/tasks/engine.rake'
|
19
|
+
|
20
|
+
|
21
|
+
|
22
|
+
Bundler::GemHelper.install_tasks
|
23
|
+
|
24
|
+
require 'rake/testtask'
|
25
|
+
|
26
|
+
Rake::TestTask.new(:test) do |t|
|
27
|
+
t.libs << 'lib'
|
28
|
+
t.libs << 'test'
|
29
|
+
t.pattern = 'test/**/*_test.rb'
|
30
|
+
t.verbose = false
|
31
|
+
end
|
32
|
+
|
33
|
+
|
34
|
+
task default: :test
|
@@ -0,0 +1,13 @@
|
|
1
|
+
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
2
|
+
// listed below.
|
3
|
+
//
|
4
|
+
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
5
|
+
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
|
6
|
+
//
|
7
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
8
|
+
// compiled file.
|
9
|
+
//
|
10
|
+
// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
|
11
|
+
// about supported directives.
|
12
|
+
//
|
13
|
+
//= require_tree .
|
@@ -0,0 +1,13 @@
|
|
1
|
+
/*
|
2
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
3
|
+
* listed below.
|
4
|
+
*
|
5
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
6
|
+
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
|
7
|
+
*
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the top of the
|
9
|
+
* compiled file, but it's generally better to create a new file per style scope.
|
10
|
+
*
|
11
|
+
*= require_self
|
12
|
+
*= require_tree .
|
13
|
+
*/
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>Cartbee</title>
|
5
|
+
<%= stylesheet_link_tag "cartbee/application", media: "all" %>
|
6
|
+
<%= javascript_include_tag "cartbee/application" %>
|
7
|
+
<%= csrf_meta_tags %>
|
8
|
+
</head>
|
9
|
+
<body>
|
10
|
+
|
11
|
+
<%= yield %>
|
12
|
+
|
13
|
+
</body>
|
14
|
+
</html>
|
data/config/routes.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
ActionController::Base.class_eval do
|
2
|
+
def current_cart
|
3
|
+
if session[:cart_id]
|
4
|
+
cart = Beecart::ShoppingCart.new(session[:cart_id])
|
5
|
+
else
|
6
|
+
session[:cart_id]
|
7
|
+
cart = Beecart::ShoppingCart.new()
|
8
|
+
session[:cart_id] = cart.key
|
9
|
+
end
|
10
|
+
|
11
|
+
cart
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,178 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
3
|
+
module Beecart
|
4
|
+
|
5
|
+
# カートに入れた商品をRedisサーバー上に保存させるためのラッパー
|
6
|
+
#
|
7
|
+
#
|
8
|
+
# 商品情報以外に
|
9
|
+
# - 顧客情報
|
10
|
+
# - 送り先住所
|
11
|
+
# - 受取先住所
|
12
|
+
# - カード情報
|
13
|
+
# - カート作成日時
|
14
|
+
# - カート更新日時
|
15
|
+
# などの情報も保存することが可能。
|
16
|
+
#
|
17
|
+
# @!attribute [rw] data
|
18
|
+
# @return [Hash] redisとのコネクションを持ったオブジェクト
|
19
|
+
#
|
20
|
+
# @!attribute [r] redis
|
21
|
+
# @return [Object] redisとのコネクションを持ったオブジェクト
|
22
|
+
#
|
23
|
+
# @!attribute [r] key
|
24
|
+
# @return [String] カートを識別するためのランダムな文字列
|
25
|
+
|
26
|
+
class ShoppingCart
|
27
|
+
|
28
|
+
ShippingColumns = {
|
29
|
+
shipping_address: [
|
30
|
+
:name, :zip, :province, :city, :address1, :address2, :tel
|
31
|
+
],
|
32
|
+
billing_address: [
|
33
|
+
:name, :zip, :province, :city, :address1,:address2, :tel
|
34
|
+
],
|
35
|
+
shipping_instruction: [
|
36
|
+
:delivery_date, :delivery_time_slot, :special_note
|
37
|
+
],
|
38
|
+
credit_card: [
|
39
|
+
:number, :cvc, :exp_year, :exp_month, :name
|
40
|
+
]
|
41
|
+
}
|
42
|
+
|
43
|
+
attr_reader :key
|
44
|
+
|
45
|
+
def initialize(cart_id=nil)
|
46
|
+
@redis = Redis.new(Beecart.redis_conf)
|
47
|
+
@key = cart_id.nil? ? SecureRandom.hex : cart_id
|
48
|
+
@data = data
|
49
|
+
end
|
50
|
+
|
51
|
+
# 保存されているデーターをredisから取り出す。
|
52
|
+
#
|
53
|
+
# @return [Hash]
|
54
|
+
def data
|
55
|
+
if @data
|
56
|
+
@data
|
57
|
+
else
|
58
|
+
load_data(@redis.get(@key))
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
# カート内のitemsを返却
|
63
|
+
# @return [Hash]
|
64
|
+
def items
|
65
|
+
data[:items]
|
66
|
+
end
|
67
|
+
|
68
|
+
# カート内の商品の合計金額を計算する
|
69
|
+
#
|
70
|
+
# @return [Integer]
|
71
|
+
def total_cost
|
72
|
+
data[:items].inject(0) do |res, (key, item)|
|
73
|
+
res += item[:price].to_i * item[:quantity].to_i
|
74
|
+
res
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
# 指定された商品を追加する
|
79
|
+
#
|
80
|
+
# @param [Hash] item_info 追加する商品の情報
|
81
|
+
# @option item_info [Integer] :price 商品の値段
|
82
|
+
# @option item_info [Integer] :quantity (0) 購入希望個数
|
83
|
+
def add_item(item_info={ quantity: 0})
|
84
|
+
|
85
|
+
unless item_info.has_key?(:price)
|
86
|
+
raise "Price needs to be passed when adding a item to cart."
|
87
|
+
end
|
88
|
+
|
89
|
+
unless item_info.has_key?(:quantity)
|
90
|
+
raise "Quantity needs to be passed when adding a item to cart."
|
91
|
+
end
|
92
|
+
|
93
|
+
@data[:items][rand_key] = item_info
|
94
|
+
|
95
|
+
dump_data
|
96
|
+
end
|
97
|
+
|
98
|
+
# 購入データを追加する
|
99
|
+
#
|
100
|
+
# @param [String] key 追加するデータの識別子
|
101
|
+
# @param [Hash] data 追加するデータ
|
102
|
+
# @return [Boolean]
|
103
|
+
def append_transaction_data(key, data)
|
104
|
+
if send(key.to_s + '_validate', data)
|
105
|
+
@data[key.to_sym] = data
|
106
|
+
dump_data
|
107
|
+
else
|
108
|
+
false
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
# 指定されたkeyにあるデータを削除する
|
113
|
+
def remove_item(key)
|
114
|
+
@data[:items].delete(key.to_sym)
|
115
|
+
|
116
|
+
dump_data
|
117
|
+
end
|
118
|
+
|
119
|
+
# 指定されたkeyにあるデータのquantityを変更する
|
120
|
+
# @param [String] key
|
121
|
+
# @param [Integer] quantity
|
122
|
+
# @return [Boolean]
|
123
|
+
def change_quantity_of key, quantity
|
124
|
+
@data[:items][key][:quantity] = quantity
|
125
|
+
|
126
|
+
dump_data
|
127
|
+
end
|
128
|
+
|
129
|
+
# Redisから削除
|
130
|
+
def destroy
|
131
|
+
@redis.del(@key)
|
132
|
+
end
|
133
|
+
|
134
|
+
private
|
135
|
+
|
136
|
+
# Redis内から取ってきたデータをデシリアイズして返却。
|
137
|
+
# またdataがnilの場合はdataのひな形を返却
|
138
|
+
#
|
139
|
+
# @param [Hash, nil]
|
140
|
+
def load_data(data)
|
141
|
+
if data.nil?
|
142
|
+
{
|
143
|
+
items: {},
|
144
|
+
user_id: nil,
|
145
|
+
shipping_address: {},
|
146
|
+
billing_address: {},
|
147
|
+
credit_card: {},
|
148
|
+
shipping_instruction: {},
|
149
|
+
created_at: Time.now.to_s,
|
150
|
+
updated_at: Time.now.to_s
|
151
|
+
}
|
152
|
+
else
|
153
|
+
symbolize(MessagePack.unpack(data))
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
157
|
+
# Redis内のデータを書き換える
|
158
|
+
def dump_data
|
159
|
+
@data[:updated_at] = Time.now.to_s
|
160
|
+
@redis.set(@key, @data.to_msgpack)
|
161
|
+
@redis.expire(@key, Beecart.expire_time)
|
162
|
+
end
|
163
|
+
|
164
|
+
# ランダムな文字列を生成
|
165
|
+
def rand_key
|
166
|
+
(0...8).map { (65 + rand(26)).chr }.join.to_sym
|
167
|
+
end
|
168
|
+
|
169
|
+
# HashのKeyをシンボルにして返却
|
170
|
+
# @return シンボルにされたHash
|
171
|
+
def symbolize hash
|
172
|
+
hash.inject({}) do |res,(key, val)|
|
173
|
+
res[key.to_sym] = val.is_a?(Hash) ? symbolize(val) : val
|
174
|
+
res
|
175
|
+
end
|
176
|
+
end
|
177
|
+
end
|
178
|
+
end
|
data/lib/beecart.rb
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
require "beecart/engine"
|
2
|
+
require "beecart/models/shopping_cart"
|
3
|
+
require "beecart/controllers/core_ext"
|
4
|
+
|
5
|
+
module Beecart
|
6
|
+
@expire_time = 20 * 60
|
7
|
+
@redis_conf = {
|
8
|
+
host: 'localhost',
|
9
|
+
port: 5555
|
10
|
+
}
|
11
|
+
|
12
|
+
|
13
|
+
|
14
|
+
class << self
|
15
|
+
#
|
16
|
+
# @!attribute [rw] expire_time
|
17
|
+
# 何秒でカートが消滅するか
|
18
|
+
# @!attribute [rw] redis_conf
|
19
|
+
# 接続するRedisへの情報
|
20
|
+
#
|
21
|
+
def expire_time=(val)
|
22
|
+
@expire_time = val
|
23
|
+
end
|
24
|
+
|
25
|
+
def expire_time
|
26
|
+
@expire_time
|
27
|
+
end
|
28
|
+
|
29
|
+
def redis_conf=(options)
|
30
|
+
@redis_conf = options.inject(@redis_conf) do |res, (key, value)|
|
31
|
+
@redis_conf[key] = value
|
32
|
+
res
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def redis_conf
|
37
|
+
@redis_conf
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
== README
|
2
|
+
|
3
|
+
This README would normally document whatever steps are necessary to get the
|
4
|
+
application up and running.
|
5
|
+
|
6
|
+
Things you may want to cover:
|
7
|
+
|
8
|
+
* Ruby version
|
9
|
+
|
10
|
+
* System dependencies
|
11
|
+
|
12
|
+
* Configuration
|
13
|
+
|
14
|
+
* Database creation
|
15
|
+
|
16
|
+
* Database initialization
|
17
|
+
|
18
|
+
* How to run the test suite
|
19
|
+
|
20
|
+
* Services (job queues, cache servers, search engines, etc.)
|
21
|
+
|
22
|
+
* Deployment instructions
|
23
|
+
|
24
|
+
* ...
|
25
|
+
|
26
|
+
|
27
|
+
Please feel free to use a different markup language if you do not plan to run
|
28
|
+
<tt>rake doc:app</tt>.
|
data/test/dummy/Rakefile
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
2
|
+
// listed below.
|
3
|
+
//
|
4
|
+
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
5
|
+
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
|
6
|
+
//
|
7
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
8
|
+
// compiled file.
|
9
|
+
//
|
10
|
+
// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
|
11
|
+
// about supported directives.
|
12
|
+
//
|
13
|
+
//= require_tree .
|
@@ -0,0 +1,27 @@
|
|
1
|
+
/*
|
2
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
3
|
+
* listed below.
|
4
|
+
*
|
5
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
6
|
+
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
|
7
|
+
*
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the top of the
|
9
|
+
* compiled file, but it's generally better to create a new file per style scope.
|
10
|
+
*
|
11
|
+
*= require_self
|
12
|
+
*= require_tree .
|
13
|
+
*/
|
14
|
+
|
15
|
+
|
16
|
+
.button {
|
17
|
+
padding: 5px 10px 5px 10px;
|
18
|
+
border: 1px solid black;
|
19
|
+
border-radius: 5px;
|
20
|
+
|
21
|
+
display: inline-block;
|
22
|
+
}
|
23
|
+
|
24
|
+
dd.item,
|
25
|
+
dt.item {
|
26
|
+
display: inline-block;
|
27
|
+
}
|
@@ -0,0 +1,43 @@
|
|
1
|
+
class CartsController < ApplicationController
|
2
|
+
|
3
|
+
before_action :get_current_cart
|
4
|
+
|
5
|
+
def index
|
6
|
+
respond_to do |format|
|
7
|
+
format.html
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
def add_item
|
12
|
+
@current_cart.add_item({
|
13
|
+
quantity: params[:items][:quantity],
|
14
|
+
price: params[:items][:price],
|
15
|
+
})
|
16
|
+
|
17
|
+
respond_to do |format|
|
18
|
+
format.html { redirect_to root_path }
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def remove_item
|
23
|
+
@current_cart.remove_item params[:items][:key]
|
24
|
+
|
25
|
+
respond_to do |format|
|
26
|
+
format.html { redirect_to root_path }
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def destroy
|
31
|
+
@current_cart.destroy
|
32
|
+
|
33
|
+
respond_to do |format|
|
34
|
+
format.html { redirect_to root_path }
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
private
|
39
|
+
|
40
|
+
def get_current_cart
|
41
|
+
@current_cart = current_cart
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
<h2>Add Item to Cart</h2>
|
2
|
+
|
3
|
+
<%= form_tag add_item_path, method: 'post' do %>
|
4
|
+
<%= text_field_tag 'items[price]', 1980 %>
|
5
|
+
<%= text_field_tag 'items[quantity]', 1 %>
|
6
|
+
<%= button_tag "Add Item A", class: "button" %>
|
7
|
+
<% end %>
|
8
|
+
|
9
|
+
<%= form_tag add_item_path, method: 'post' do %>
|
10
|
+
<%= text_field_tag 'items[price]', 19080 %>
|
11
|
+
<%= text_field_tag 'items[quantity]', 3 %>
|
12
|
+
<%= button_tag "Add Item B", class: "button" %>
|
13
|
+
<% end %>
|
14
|
+
|
15
|
+
<hr />
|
16
|
+
|
17
|
+
<h2>Your Current Cart Status</h2>
|
18
|
+
|
19
|
+
<%# <%= @current_cart %>
|
20
|
+
|
21
|
+
<dt>Cart Key:</dt>
|
22
|
+
<dd><%= @current_cart.key %></dd>
|
23
|
+
|
24
|
+
<dt>Total Cost:</dt>
|
25
|
+
<dd><%= @current_cart.total_cost %></dd>
|
26
|
+
|
27
|
+
<dt>Items:</dt>
|
28
|
+
<dd class="item_list">
|
29
|
+
<%= @current_cart.items.each do |key, item| %>
|
30
|
+
<dt class="item">Price</dt>
|
31
|
+
<dd class="item"><%= item[:price] %></dd>
|
32
|
+
<br />
|
33
|
+
<dt class="item">Quantity</dt>
|
34
|
+
<dd class="item"><%= item[:quantity] %></dd>
|
35
|
+
|
36
|
+
<%= form_tag remove_item_path, method: 'delete' do %>
|
37
|
+
<%= hidden_field_tag 'items[key]', key %>
|
38
|
+
<%= button_tag "Remove This Item", class: "button" %>
|
39
|
+
<% end %>
|
40
|
+
<hr />
|
41
|
+
<% end %>
|
42
|
+
</dd>
|
43
|
+
|
44
|
+
<dt>Created at:</dt>
|
45
|
+
<dd><%= @current_cart.data[:created_at] %></dd>
|
46
|
+
|
47
|
+
<dt>Updated at:</dt>
|
48
|
+
<dd><%= @current_cart.data[:updated_at] %></dd>
|
49
|
+
|
50
|
+
<hr />
|
51
|
+
|
52
|
+
<h2>Delete Cart</h2>
|
53
|
+
|
54
|
+
<%= form_tag destroy_cart_path, method: 'delete' do %>
|
55
|
+
<%= button_tag "Destroy Cart", class: "button" %>
|
56
|
+
<% end %>
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>Dummy</title>
|
5
|
+
<%= stylesheet_link_tag "application", media: "all", "data-turbolinks-track" => true %>
|
6
|
+
<%= javascript_include_tag "application", "data-turbolinks-track" => true %>
|
7
|
+
<%= csrf_meta_tags %>
|
8
|
+
</head>
|
9
|
+
<body>
|
10
|
+
|
11
|
+
<%= yield %>
|
12
|
+
|
13
|
+
</body>
|
14
|
+
</html>
|
data/test/dummy/bin/rake
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
require File.expand_path('../boot', __FILE__)
|
2
|
+
|
3
|
+
require 'rails/all'
|
4
|
+
|
5
|
+
Bundler.require(*Rails.groups)
|
6
|
+
require "beecart"
|
7
|
+
|
8
|
+
module Dummy
|
9
|
+
class Application < Rails::Application
|
10
|
+
# Settings in config/environments/* take precedence over those specified here.
|
11
|
+
# Application configuration should go into files in config/initializers
|
12
|
+
# -- all .rb files in that directory are automatically loaded.
|
13
|
+
|
14
|
+
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
|
15
|
+
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
|
16
|
+
# config.time_zone = 'Central Time (US & Canada)'
|
17
|
+
|
18
|
+
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
|
19
|
+
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
|
20
|
+
# config.i18n.default_locale = :de
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# SQLite version 3.x
|
2
|
+
# gem install sqlite3
|
3
|
+
#
|
4
|
+
# Ensure the SQLite 3 gem is defined in your Gemfile
|
5
|
+
# gem 'sqlite3'
|
6
|
+
development:
|
7
|
+
adapter: sqlite3
|
8
|
+
database: db/development.sqlite3
|
9
|
+
pool: 5
|
10
|
+
timeout: 5000
|
11
|
+
|
12
|
+
# Warning: The database defined as "test" will be erased and
|
13
|
+
# re-generated from your development database when you run "rake".
|
14
|
+
# Do not set this db to the same as development or production.
|
15
|
+
test:
|
16
|
+
adapter: sqlite3
|
17
|
+
database: db/test.sqlite3
|
18
|
+
pool: 5
|
19
|
+
timeout: 5000
|
20
|
+
|
21
|
+
production:
|
22
|
+
adapter: sqlite3
|
23
|
+
database: db/production.sqlite3
|
24
|
+
pool: 5
|
25
|
+
timeout: 5000
|