Search code examples
devisesidekiq

Sidekiq Web Fails undefined method `failure_app' for nil:NilClass


I have Sidekiq installed as follows:

  require 'sidekiq/web'
  Sidekiq::Web.set :sessions, false

  authenticate :admin do
    mount Sidekiq::Web => '/admin/sidekiq'
  end

Now Sidekiq web fails when I try to access it - this is local and in production.

NoMethodError at /unauthenticated
undefined method `failure_app' for nil:NilClass

failure_appdevise (4.7.1) lib/devise/delegator.rb

def failure_app(env)
  app = env["warden.options"] &&
    (scope = env["warden.options"][:scope]) &&
    Devise.mappings[scope.to_sym].failure_app
  app || Devise::FailureApp
end

Solution

  • Stumbled on this:

    https://github.com/mperham/sidekiq/issues/2963#issuecomment-219590441

      devise_for :admin_users, ActiveAdmin::Devise.config
    
      authenticate :admin_user do
        mount Sidekiq::Web => '/admin/sidekiq'
      end
    

    I had two mistakes in my code:

    1. I was trying to authenticate Sidekiq via :admin and NOT :admin_user
    2. Note the SINGULAR :admin_user - I still had the plural once I finally figure #1 out 🤦‍♂️