How to automatically set all links to nofollow in Rails

此生再无相见时 提交于 2019-12-04 03:43:54
Jesse Wolgamott

In your application helper you can override the link_to method and replace with your own.

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

You could create an alias to the old link_to then override it so it calls the old alias with the extra parameter. That way, you don't have to change all the existing link_to in your code.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!