Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我在某个地方找到了helper 中的哪个:back选项有以下代码:link_to
:back
link_to
@controller.request.env["HTTP_REFERER"] || 'javascript:history.back()
我在哪里可以改变它?
它实际上是使用url_for助手。您可以在帮助程序中覆盖它。例如,将它放在 Rails 应用程序的 application_helper.rb 中:
url_for
def url_for(options = {}) if options == :back # replace this with your code controller.request.env["HTTP_REFERER"] || 'javascript:history.back()' else super(options) end end