Tag Archives: devise

Rails: How to Solve devise error undefined method failure_app for nil class

I bumped into the following error when I was creating API program. The origin was devise gem.

NoMethodError (undefined method `failure_app’ for nil:NilClass)


  • Ruby 2.2.3p173
  • Rails 4.2.4
  • devise 3.5.2


I used sign_in method for unauthorized user.

The API in construction, we have to make unauthorized user able to login, so I wrote logging in procedure for all users, including unauthorized users. Then, devise and warden rejected unauthorized user and raised error.


Write the following setting into config/initializer/devise.rb.

Or write the following method into the model class that is used by devise for authentication. User class for example.

I recommend latter solution.


confirmation_period_valid? method is defined at the module Devise::Models::Confirmable of devise gem.