Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting turbolinks wrapper to work with Ruby on Rails Devise

For my App, I am trying to set up the Turbolinks Mobile wrapper> . I am running into an issue where I can't sign into the App (and thinking the issues is that I need to modify Devise to get it to switch to XHR to work for the mobile). My sign_in form uses Devise but I can't see the code.

Using: ruby "2.4.0" gem "rails", "5.0.2" gem "turbolinks", "~> 5.0.0.beta" gem "devise", ">= 4.2.0" gem "devise-async", git: "https://github.com/mhfs/devise-async", branch: "devise-4.x" # for user authentication

My question is where to I look or what do I need to do to amend DEVISE to have it be able to send the XHR for the turbolinks mobile wrapper?

Right now, it won't sign in and I know (or I am thinking) I need to get DEVISE to switch to XHR but I don't know how.

Suggestions on how to do this? Or recommendations on reference material?

like image 240
user2970050 Avatar asked Oct 18 '22 15:10

user2970050


1 Answers

You need to update your devise initializer to accept ajax requests.

config.http_authenticatable_on_xhr = false
config.navigational_formats = ["*/*", :html, :json]

You will probably need to update your registration and session controllers to respond to json also.

format.json { render json: resource }
like image 155
Stephen Avatar answered Oct 21 '22 02:10

Stephen