Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Completed 406 Not Acceptable in devise

I am integrating ios app with rails server. Here, I have implemented devise authentication. when a new person is signing up from my app, I get the following error in my logs

Processing by Devise::RegistrationsController#create as JSON
Parameters: {"password_confirmation"=>"[FILTERED]", "email"=>"[email protected]", "password"=>"[FILTERED]", "registration"=>{"password_confirmation"=>"[FILTERED]", "email"=>"[email protected]", "password"=>"[FILTERED]"}}
WARNING: Can't verify CSRF token authenticity
(0.1ms)  begin transaction
(0.0ms)  rollback transaction
Completed 406 Not Acceptable in 28ms (ActiveRecord: 0.7ms)
like image 264
Santh Nish Avatar asked Aug 08 '13 10:08

Santh Nish


2 Answers

Devise responding to json by default has been removed from version 2.2, So add

respond_to :json

in your application controller or the specific controller where you would like to respond with json.

like image 64
logesh Avatar answered Sep 28 '22 01:09

logesh


To not allow json acceptance for all controllers, but only for devise add

config.to_prepare do
  DeviseController.respond_to :html, :json
end

only to config/application.rb as recommended here https://github.com/plataformatec/devise/issues/2209

like image 32
Petr Avatar answered Sep 28 '22 02:09

Petr