简体   繁体   中英

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. 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?

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

I have just found out that WEBrick handles request.referrer incorrectly. But don't worry. Unicorn handles it right. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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