2012-10-08 35 views
1

我在什麼地方找到什麼:back選項link_to助手有這樣的代碼:修改軌道的link_to助手

@controller.request.env["HTTP_REFERER"] || 'javascript:history.back()

在那裏我可以改變呢?

回答

2

它實際上是使用url_for幫手。你可以在幫手中覆蓋它。例如,將其放入您的Rails應用程序的application_helper.rb中:

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