我正在使用
<li><%= link_to_unless_current("Home", root_path) %></li>
当它们不在根路径时,在导航栏上显示主页链接。它工作正常,只是当它们位于根路径时,它会在文本“Home”(不是链接,只是文本)后面留下。
我确定有更好的方法可以做到这一点,有什么建议吗?
最佳答案
link_to("Home", root_path) unless current_page?(root_url)
关于ruby-on-rails - rails : conditional home link,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12292717/