Now I am using the devise gem, and after successful authorization it redirects user to the root page.
How to modify sign_in action to return json array like this: {"auth_result":"1"} instead of redirect?
Is it possible?
I haven’t found recipes for these in devise wiki.
Devise currently does not handle JSON responses – see the issue on github. Therefore you would have to create a custom sessions_controller to handle your response. Take a look at the implementation on github to get an idea. I threw together some rough pseudo code that will hopefully get you started:
Then in your routes.rb file you will have to specify your new controller –
devise_for :users, :controllers => { :sessions => "users/sessions" }Hope this helps!