如何在Rails中自动将所有链接设置为nofollow

deb*_*deb 8 ruby ruby-on-rails nofollow

我知道我可以传递:rel => "nofollow"link_to,但有什么办法来设置,默认情况下,所以我不必使每个变化link_to标签?

Jes*_*ott 20

在您的应用程序助手中,您可以覆盖该link_to方法并替换为您自己的方法.

def link_to(name, options = {}, html_options = {})
  html_options.merge!(:rel => :nofollow)
  super(name, options, html_options)
end
Run Code Online (Sandbox Code Playgroud)