-
-
Notifications
You must be signed in to change notification settings - Fork 130
Configuring devise for APIs
Marc Busqué edited this page Dec 11, 2017
·
4 revisions
In order for devise to know it can respond to json format, you need to instruct the controller layer. Usually you will add the following in ApplicationController:
respond_to :jsonIf you are inheriting from ActionController::API, first you will need to take that functionality back:
include ActionController::MimeRespondsIf you want devise routes to use json as default format (that is, you don't need to add .json at the end of the URLs), use defaults as the following:
devise_for :users, defaults: { format: :json }If you are developing an API, probably you don't need session storage. If you are in a regular Rails application (not created with the --api flag), you can disable them in config/initializers/session_store.rb:
Rails.application.config.session_store :disabled