Search code examples
ruby-on-railsrubysessioncapistranosidekiq

How do I set my new secret key base for Sidekiq in Rails?


I am using the following gems in my application.

gem 'activerecord-session_store'
gem 'sidekiq'
gem 'sidekiq-unique-jobs'
gem 'sidekiq-cron'
gem 'sinatra', require: false
gem 'capistrano-sidekiq', github: 'seuros/capistrano-sidekiq'

I recently started using activerecord-session_store and in the process I remember having to update my secret_key_base for my application. Now when I try to make changes through the SideKiq admin panel I always get a blank white page that says "forbidden". I'm guessing that my session is not being shared correctly? How can I set up SideKiq to use the same secret_key_base as my application?


Solution

  • You can do the following to share Rails' secret key base with Sidekiq web interface:

    Sidekiq::Web.set :session_secret, Rails.application.secrets[:secret_key_base]