Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Support invalid cookies. Version bump 1.2.2

  • Loading branch information...
commit 684cae172365ba44d8dd9c516480f2135b74e8bb 1 parent 2baa85b
@potatosalad authored
View
2  Gemfile.lock
@@ -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)
View
11 lib/mongoid/data_table/proxy.rb
@@ -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)
View
2  lib/mongoid/data_table/version.rb
@@ -1,5 +1,5 @@
module Mongoid
module DataTable
- VERSION = "1.2.1"
+ VERSION = "1.2.2"
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.