Skip to content
This repository was archived by the owner on Jul 24, 2020. It is now read-only.

Commit c9978e3

Browse files
committed
Method make_cart_compatible to ensure backwards compatibility afte #587, as per #667
1 parent aacd293 commit c9978e3

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

app/controllers/application_controller.rb

+10
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ class ApplicationController < ActionController::Base
1818
c.before_filter :fix_cart_date
1919
c.before_filter :set_view_mode
2020
c.before_filter :check_view_mode
21+
c.before_filter :make_cart_compatible
2122
end
2223

2324
helper_method :current_user
@@ -114,6 +115,15 @@ def fix_cart_date
114115
cart.fix_due_date
115116
end
116117

118+
# If user's session has an old Cart object that stores items in Array rather
119+
# than a Hash (see #587), regenerate the Cart.
120+
# TODO: Remove in ~2015, when nobody could conceivably run the old app?
121+
def make_cart_compatible
122+
if session[:cart].items.is_a? Array
123+
session[:cart] = Cart.new
124+
end
125+
end
126+
117127
#-------- end before_filter methods --------#
118128

119129
def update_cart

0 commit comments

Comments
 (0)