简体   繁体   English

Rails 3获取请求引用者

[英]Rails 3 get request referrer

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. 我正在使用Rails 3.0.9,Ruby 1.9.2,Devise 1.3.4并且需要在Devise会话中使用新视图来访问请求url参数,尽管我将此视为一般的Rails请求处理问题。 Essentially, a request is made to a Devise authenticated resource which redirects the user to the login screen. 实质上,向Devise认证资源发出请求,该资源将用户重定向到登录屏幕。 In the login view, I need access to the request url, eg, this is the request url called in the beginning 在登录视图中,我需要访问请求URL,例如,这是在开头调用的请求URL

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? 在重定向登录页面中,我需要访问该URL,任何人都知道我该怎么做?

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

I have just found out that WEBrick handles request.referrer incorrectly. 我刚刚发现WEBrick错误地处理request.referrer But don't worry. 但别担心。 Unicorn handles it right. Unicorn正确处理它。 I did't test that on other servers. 我没有在其他服务器上测试过。 You should check this with yours. 你应该和你的一起检查一下。 I don't think that you use WEBrick as a production server. 我不认为你使用WEBrick作为生产服务器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM