shop_bunny 0.7.4.17 → 0.7.4.18
Sign up to get free protection for your applications and to get access to all the features.
data/app/models/cart_item.rb
CHANGED
@@ -27,7 +27,9 @@ class CartItem < ActiveRecord::Base
|
|
27
27
|
def item
|
28
28
|
return nil unless raw_item
|
29
29
|
unless @parsed_raw_item
|
30
|
-
json = JSON.parse(raw_item)
|
30
|
+
json = JSON.parse(raw_item)
|
31
|
+
json = json.values.first if json.kind_of?(Array)
|
32
|
+
|
31
33
|
if json
|
32
34
|
@parsed_raw_item = ShopBunny.item_model_class_name.constantize.new(json)
|
33
35
|
@parsed_raw_item.id = json['id']
|
@@ -3,9 +3,12 @@ class AddRawItemToCartItems < ActiveRecord::Migration
|
|
3
3
|
add_column :cart_items, :raw_item, :text
|
4
4
|
|
5
5
|
CartItem.all.each do |e|
|
6
|
-
if e.
|
7
|
-
|
8
|
-
|
6
|
+
if e.read_attribute(:item_id)
|
7
|
+
i = ShopBunny.item_model_class_name.constantize.find_by_id(e.read_attribute(:item_id))
|
8
|
+
if i
|
9
|
+
e.raw_item = i.to_json
|
10
|
+
e.save!
|
11
|
+
end
|
9
12
|
end
|
10
13
|
end
|
11
14
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shop_bunny
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 67
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 7
|
9
9
|
- 4
|
10
|
-
-
|
11
|
-
version: 0.7.4.
|
10
|
+
- 18
|
11
|
+
version: 0.7.4.18
|
12
12
|
platform: ruby
|
13
13
|
authors:
|
14
14
|
- kopfmaschine.com
|