Getting turbolinks wrapper to work with Ruby on Rails Devise

巧了我就是萌 提交于 2021-02-07 14:52:49

问题


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?


回答1:


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 }


来源:https://stackoverflow.com/questions/42860934/getting-turbolinks-wrapper-to-work-with-ruby-on-rails-devise

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!