saibharath
saibharath

Reputation: 63

Undefined method `to' for nil:NilClass + devise + rails

I am using Devise in my Rails application. For some users I am getting this kind of error:

undefined method 'to' for nil:NilClass from this method

def http_auth_header?
 Devise.mappings[scope].to.http_authenticatable && !request.xhr?
end

that is from Devise itself.

How can I resolve this?

Upvotes: 2

Views: 564

Answers (1)

Christophe Dufour
Christophe Dufour

Reputation: 165

I spent time to fix the same issue.

I did some custom stuff into the SessionController :

resource = warden.authenticate!(:scope => "user", :recall => "#{controller_path}#failure")

And in fact, scope MUST BE a symbol :

resource = warden.authenticate!(:scope => :user, :recall => "#{controller_path}#failure")

So I think you just provide a scope as a String instead of a symbol

Hope it helps ;)

Upvotes: 2

Related Questions