Ruby on Rails:如果是当前页面? 是主页,不显示表格

我想不显示表单,但仅限当前页面不是主页

这就是我到目前为止……

我有我的路线设置:

root 'projects#index' 

我的看法:

  'projects', :action => 'index')) %> show some stuff  

如果url是localhost:3000/projects ,则不显示

但是它显示了它的localhost:3000

所以我需要以某种方式确保如果它的主页,它将不会显示。 另外,我有主页的搜索参数,我仍然不想显示它是否像localhost:3000/projects?search=blahblahblah

使用root_path帮助器:

 <% unless current_page?(root_path) %> show some stuff <% end %> 

这不显示url是否为localhost:3000/projects但是它显示的是localhost:3000

要么:

 <% unless current_page?('/') || current_page?('/projects') %> # '/' the same as root_path show some stuff <% end %> 

另外,根据documentation ,不需要url_for方法:

 current_page?(controller: 'projects', action: 'index')