Undefined method failure_app for nil:NilClass
Asked Answered
P

2

10

I am trying to use devise from a Rails app to grant access to a Sinatra application within the Rack middleware.

My config/routes.rb has:

authenticate "admin" do
  mount Admins::Dashboard, :at => "/admins"                                                                                                        
end

In my Sinatra app, I use:

before do
  env["warden"].authenticate!(:scope => "admin")                                                                                                 
end

get "/dashboard" do
  erb :dashboard
end

Now, I get an error with the following stacktrace:

Started GET "/admins/dashboard" for 127.0.0.1 at 2012-10-11 08:45:13 +0200

NoMethodError (undefined method `failure_app' for nil:NilClass):
  devise (2.1.2) lib/devise/delegator.rb:11:in `failure_app'
  devise (2.1.2) lib/devise/delegator.rb:5:in `call'
  warden (1.2.1) lib/warden/manager.rb:130:in `call_failure_app'
  warden (1.2.1) lib/warden/manager.rb:116:in `process_unauthenticated'
  warden (1.2.1) lib/warden/manager.rb:47:in `call'
  actionpack (3.2.8) lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
  rack (1.4.1) lib/rack/etag.rb:23:in `call'
  rack (1.4.1) lib/rack/conditionalget.rb:25:in `call'
Peru answered 11/10, 2012 at 6:55 Comment(0)
U
3

The error message is a complaint about missing configuration for customizing the warden failure app to point to sinatra.

Check out this previous answer and the related (detailed) blogpost about setting up Sinatra+Warden & Rails+Devise; hopefully the instructions there will help you implement the solution successfully.

Unfriended answered 11/10, 2012 at 23:26 Comment(0)
R
2

Had the same error message and this comment on Github helped me out.

In my sessions_controller.rb I had:

sign_in(:user, @resource, store: false, bypass: false)

which I replaced with:

sign_in(:users, @resource, store: false, bypass: false)

for it to work.

Specifically, the issue was only happening after one user would delete his account... Also I am using devise_token_auth (hence the overriden sessions controller).

Rinee answered 24/5, 2018 at 13:36 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.