2010-08-20 47 views

回答

20

在您的應用幫手中,您可以覆蓋link_to方法並用您自己的方法替換。

def link_to(name, options = {}, html_options = {}) 
    html_options.merge!(:rel => :nofollow) 
    super(name, options, html_options) 
end 
+0

如果你不想已經覆蓋你的鏈接上的任何'rel'值,請嘗試使用''merge_nicely改爲:https://gist.github.com/joshuapinter/78a5545d713ab9d55883 – 2014-09-21 05:01:58

2

您可以爲舊的link_to創建別名,然後覆蓋它,以便使用額外參數調用舊別名。這樣,您不必更改代碼中現有的所有link_to

相關問題