10

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"=>"sss@example.com", "password"=>"[FILTERED]", "registration"=>{"password_confirmation"=>"[FILTERED]", "email"=>"sss@example.com", "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)
Taylan Aydinli
  • 4,333
  • 15
  • 39
  • 33
Santh Nish
  • 169
  • 2
  • 15
  • Any of those help? http://stackoverflow.com/questions/7203304/warning-cant-verify-csrf-token-authenticity-rails, http://stackoverflow.com/questions/9362910/rails-warning-cant-verify-csrf-token-authenticity-for-json-devise-requests – CBroe Aug 08 '13 at 14:04

2 Answers2

15

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.

logesh
  • 2,572
  • 4
  • 33
  • 60
2

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

Petr
  • 3,214
  • 18
  • 21