Rails: Undefined method `flash' for ActionDispatch::Request

Not sure but maybe you need to include the ActionDispatch::Flash middleware to support the flash. Using:

config.middleware.use ActionDispatch::Flash

The docs says:

ActionDispatch::Flash: Supports the flash mechanism in ActionController.

I hope it helps


See: https://github.com/plataformatec/devise/issues/2775

Inside devise.rb change

config.navigational_formats = ['*/*', :html]

to:

config.navigational_formats = [:json]

or just [ ]


If you're like me and creating an API on top of an existing application, you can add this to your config/application.rb file:

config.api_only = false