Rails 3 获取请求引用 [英] Rails 3 get request referrer

查看:10
本文介绍了Rails 3 获取请求引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Rails 3.0.9、Ruby 1.9.2、Devise 1.3.4,并且需要在 Devise 会话新视图中访问请求 url 参数,尽管我认为这是一个通用的 Rails 请求处理问题.本质上,向 Devise 认证资源发出请求,该请求将用户重定向到登录屏幕.在登录视图中,我需要访问请求url,例如,这是开头调用的请求url

I'm using Rails 3.0.9, Ruby 1.9.2, Devise 1.3.4 and has a need in Devise session new view to access the request url parameters although I see this as a general Rails request handling question. Essentially, a request is made to a Devise authenticated resource which redirects the user to the login screen. In the login view, I need access to the request url, eg, this is the request url called in the beginning

http://mysite.com/article/5?type=blah

在重定向登录页面中,我需要访问该 URL,有人知道我该怎么做吗?

In the redirect login page, I need access to that URL, anyone know how I can do this?

推荐答案

您可以在控制器中使用 request.refererrequest.env['HTTP_REFERER'] 来获取引用网址.

You can use request.referer or request.env['HTTP_REFERER'] in your controller to get the referer url.

这篇关于Rails 3 获取请求引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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