1
0
Fork 0
mirror of https://github.com/mperham/sidekiq.git synced 2022-11-09 13:52:34 -05:00

Monkeypatch Rails session store to support each, #2460

This commit is contained in:
Mike Perham 2015-08-31 10:57:03 -07:00
parent f8ee089607
commit 935b9eb2f6
2 changed files with 13 additions and 15 deletions

View file

@ -262,3 +262,16 @@ module Sidekiq
end
end
end
if defined?(::ActionDispatch::Request::Session) &&
!::ActionDispatch::Request::Session.respond_to?(:each)
# mperham/sidekiq#2460
# Rack apps can't reuse the Rails session store without
# this monkeypatch
class ActionDispatch::Request::Session
def each(&block)
hash = self.to_hash
hash.each(&block)
end
end
end

View file

@ -6,18 +6,3 @@ Myapp::Application.config.session_store :cookie_store, key: '_myapp_session'
# which shouldn't be used to store highly confidential information
# (create the session table with "rails generate session_migration")
# Myapp::Application.config.session_store :active_record_store
# Monkeypatch necessary due to https://github.com/rails/rails/issues/15843
require 'rack/session/abstract/id'
class Rack::Session::Abstract::SessionHash
private
def stringify_keys(other)
hash = {}
other = other.to_hash unless other.is_a?(Hash) # hack hack hack
other.each do |key, value|
hash[key.to_s] = value
end
hash
end
end