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

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

问题描述

我使用的是Rails 3.0.9,Ruby 1.9.2,Devise 1.3.4,并且在Devise会话新视图中需要访问请求url参数,尽管我将其视为一般的Rails请求处理问题。本质上,向Devise认证资源提出了一个请求,将资源重定向到登录界面。在登录视图中,我需要访问请求url,例如,这是开头调用的请求url

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

在重定向登录页面中,我需要

解决方案

您可以使用 request.referer request.env ['HTTP_REFERER'] 在您的控制器中获取引荐网址。


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

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

解决方案

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

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

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