1
0
Fork 0
mirror of https://github.com/heartcombo/devise.git synced 2022-11-09 12:18:31 -05:00

Added mention of API mode complications to README (#5041) [ci skip]

This commit is contained in:
emersonthis 2019-03-14 14:19:45 -07:00 committed by Leonardo Tegon
parent 1102600720
commit 2f3a59640b

View file

@ -56,6 +56,7 @@ It's composed of 10 modules:
- [ActiveJob Integration](#activejob-integration) - [ActiveJob Integration](#activejob-integration)
- [Password reset tokens and Rails logs](#password-reset-tokens-and-rails-logs) - [Password reset tokens and Rails logs](#password-reset-tokens-and-rails-logs)
- [Other ORMs](#other-orms) - [Other ORMs](#other-orms)
- [Rails API mode](#rails-api-mode)
- [Additional information](#additional-information) - [Additional information](#additional-information)
- [Heroku](#heroku) - [Heroku](#heroku)
- [Warden](#warden) - [Warden](#warden)
@ -694,6 +695,17 @@ config.log_level = :warn
Devise supports ActiveRecord (default) and Mongoid. To select another ORM, simply require it in the initializer file. Devise supports ActiveRecord (default) and Mongoid. To select another ORM, simply require it in the initializer file.
### Rails API Mode
Rails 5+ has a built-in [API Mode](https://edgeguides.rubyonrails.org/api_app.html) which optimizes Rails for use as an API (only). One of the side effects is that it changes the order of the middleware stack, and this can cause problems for `Devise::Test::IntegrationHelpers`. This problem usually surfaces as an ```undefined method `[]=' for nil:NilClass``` error when using integration test helpers, such as `#sign_in`. The solution is simply to reorder the middlewares by adding the following to test.rb:
```ruby
Rails.application.config.middleware.insert_before Warden::Manager, ActionDispatch::Cookies
Rails.application.config.middleware.insert_before Warden::Manager, ActionDispatch::Session::CookieStore
```
For a deeper understanding of this, review [this issue](https://github.com/plataformatec/devise/issues/4696).
## Additional information ## Additional information
### Heroku ### Heroku