Ruby on rails ';当前页面&x27;不处理应用程序布局
我有一个显示商店列表的rails应用程序。我试图让它在用户位于shops页面(/merchant/:username)时隐藏标题 在my application.html.erb中Ruby on rails ';当前页面&x27;不处理应用程序布局,ruby-on-rails,ruby,Ruby On Rails,Ruby,我有一个显示商店列表的rails应用程序。我试图让它在用户位于shops页面(/merchant/:username)时隐藏标题 在my application.html.erb中 <% if current_page?(menu_path) %> <% else %> <%= render "shared/header" %> <% end %> 我还尝试: <% if current_page?(:controlle
<% if current_page?(menu_path) %>
<% else %>
<%= render "shared/header" %>
<% end %>
我还尝试:
<% if current_page?(:controller => 'merchants', :action => 'show') %>
及
您的路线需要一个参数(:username
),当您在主页上时,该参数不存在
您可以尝试以下方法:
编辑:添加了controller\u name
也许您可以使用
content\u来查看商家视图中的部分内容。我认为您在当前的帮助页面中缺少用户名键
当前页面?(控制器:'merchants',操作:'show',用户名:'example')
什么是当前页面返回?谢谢,这很有效,但是如果我有另一个控制器也有一个名为“show”的操作,那么我假设这也会隐藏该路由的标题,这是一种仅为商户控制器指定标题的方法吗?当然,您可以使用控制器名称
。我更新了我的答案。
<% if current_page?(:controller => 'merchants', :action => 'show') %>
No route matches {:action=>"show", :controller=>"merchants"}
No route matches {:action=>"show", :controller=>"merchants"}, missing required keys: [:username]