使Turbolinks包装器与Ruby on Rails Devise一起使用 [英] Getting turbolinks wrapper to work with Ruby on Rails Devise

查看:47
本文介绍了使Turbolinks包装器与Ruby on Rails Devise一起使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于我的应用程序,我正在尝试设置Turbolinks Mobile包装器>.我遇到了无法登录该应用程序的问题(并认为问题是我需要修改Devise才能使其切换到XHR才能在移动设备上工作).我的sign_in表单使用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.

<代码>使用:红宝石"2.4.0"宝石"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",分支:"devise-4.x"#用于用户身份验证

我的问题是我应该去哪里寻找或修改DEVISE,使其能够为Turbolinks移动包装发送XHR?

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?

现在,它无法登录,我知道(或者我在想)我需要让DEVISE切换到XHR,但我不知道如何.

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?

推荐答案

您需要更新devise初始化程序以接受ajax请求.

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

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

您可能需要更新注册和会话控制器,才能同时响应json.

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

format.json { render json: resource }

这篇关于使Turbolinks包装器与Ruby on Rails Devise一起使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆