Permalink
Browse files

Support invalid cookies. Version bump 1.2.2

  • Loading branch information...
1 parent 2baa85b commit 684cae172365ba44d8dd9c516480f2135b74e8bb @potatosalad committed Aug 4, 2011
Showing with 11 additions and 4 deletions.
  1. +1 −1 Gemfile.lock
  2. +9 −2 lib/mongoid/data_table/proxy.rb
  3. +1 −1 lib/mongoid/data_table/version.rb
View
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
- mongoid-data_table (1.2.1)
+ mongoid-data_table (1.2.2)
kaminari (~> 0.12.4)
rails (>= 3.0.0)
@@ -9,6 +9,7 @@ class Proxy < ::Mongoid::Relations::Proxy
:controller,
:cookies,
:cookie,
+ :cookie_prefix,
:options,
:extension,
:params,
@@ -35,8 +36,14 @@ def initialize(klass, controller, options = {}, &block)
params[:iDisplayLength] = conditions.count if (params[:iDisplayLength].to_i rescue 0) == -1
- @cookie = @cookies["SpryMedia_DataTables_#{options[:sInstance]}"]
- @cookie = ::JSON.load(@cookie) if @cookie.is_a?(String)
+ @cookie_prefix = options[:cookie_prefix] || 'SpryMedia_DataTables_'
+ @cookie = @cookies["#{cookie_prefix}#{options[:sInstance]}"]
+ begin
+ @cookie = ::JSON.load(cookie) if @cookie.is_a?(String)
+ rescue
+ @cookie = nil
+ @cookies.delete "#{cookie_prefix}#{options[:sInstance]}"
+ end
end
def collection(force = false)
@@ -1,5 +1,5 @@
module Mongoid
module DataTable
- VERSION = "1.2.1"
+ VERSION = "1.2.2"
end
end

0 comments on commit 684cae1

Please sign in to comment.