Ruby on Rails:如何获取之前的 URL? [英] Ruby on Rails: How do you get the previous URL?
本文介绍了Ruby on Rails:如何获取之前的 URL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Rails 中如何获取之前的 URL?不是您收到请求的网址,而是之前的网址?
How to get the previous URL in Rails? Not the URL that you got a request from, but the one before that?
因为我收到一个 AJAX 请求,我需要他们当前所在页面的 URL(或 AJAX 之前的 URL).
Because I'm getting an AJAX request, and I need the URL for the page they are currently on (or the URL before the AJAX).
推荐答案
尝试使用 HTTP_REFERER
.
在 Rails 中:request.referrer
或 request.headers["HTTP_REFERER"]
In Rails: request.referrer
or request.headers["HTTP_REFERER"]
这篇关于Ruby on Rails:如何获取之前的 URL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文