From 9591d8cbaf1e90b87e4f6f7e38ce6838a4c25bcb Mon Sep 17 00:00:00 2001 From: Mike Perham Date: Wed, 29 Jul 2015 09:55:35 -0700 Subject: [PATCH] Remove explicit session use, add monkeypatch for Rails bug, #2460 --- myapp/config/application.rb | 1 + myapp/config/initializers/session_store.rb | 15 +++++++++++++++ myapp/simple.ru | 3 +-- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/myapp/config/application.rb b/myapp/config/application.rb index 422b350a..fc0399f5 100644 --- a/myapp/config/application.rb +++ b/myapp/config/application.rb @@ -55,5 +55,6 @@ module Myapp # Version of your assets, change this if you want to expire all your assets config.assets.version = '1.0' + config.secret_key_base = "sidekiq" end end diff --git a/myapp/config/initializers/session_store.rb b/myapp/config/initializers/session_store.rb index efa55838..12441f01 100644 --- a/myapp/config/initializers/session_store.rb +++ b/myapp/config/initializers/session_store.rb @@ -6,3 +6,18 @@ 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 diff --git a/myapp/simple.ru b/myapp/simple.ru index b3c19dc6..51bc5f60 100644 --- a/myapp/simple.ru +++ b/myapp/simple.ru @@ -5,9 +5,8 @@ require 'sidekiq' # A Web process always runs as client, no need to configure server Sidekiq.configure_client do |config| - config.redis = { url: 'redis://localhost:6379/0', size: 1 } + config.redis = { url: 'redis://localhost:6379/0', size: 1, namespace: 'foo' } end require 'sidekiq/web' -use Rack::Session::Cookie, :secret => "some unique secret string here" run Sidekiq::Web