我有一个case when子句,根据你所在的URL,它会带来不同的菜单选项。但是,根据您可能在的一些菜单,它无法识别您已分配的一些变量。系统错误:
ActionController::RoutingError in Pages#users_page
Showing /home/initiald/RubymineProjects/SOWOnline/app/views/layouts/_navigation.html.erb where line #27 raised:
No route matches {:controller=>"results", :action=>"show"}
这是目前为止我写的代码
<% case request.path %>
<% #ROOT AND SETTINGS %>
<% when '/', settings_path, '/guest' %>
<% #SURVEY AND RESULTS %>
<% when '/sow_survey', '/surveys', '/results', result_path, results_path, available_surveys_path, take_survey_path, view_my_survey_path, edit_my_survey_path %>
<% if permitted_to? [:admin, :partner, :employee], :users %>
<%= link_to 'new survey', available_surveys_path %>
<%= link_to 'edit survey', results_path %>
<% end %>
<% #USERS %>
<% when '/register' , '/users', '/sow_users', edit_user_path %>
<% if permitted_to? [:admin, :partner, :employee], :users %>
<%= link_to 'new user', register_path %>
<%= link_to 'list users', list_users_path %>
<% end %>
<% else %>
<% end %>
不存在没有属性的result_path
,但存在result_path(result_id)
路径,即:
{:controller=>"results", :action=>"show", :id => your_paticular_id}
,看起来像
/results/:id
乌利希期刊指南
只需在这里使用正则表达式:
<% when '/sow_survey', '/surveys', '/results', //results/d*/, results_path, available_surveys_path, take_survey_path, view_my_survey_path, edit_my_survey_path %>
是的,你的代码很乱。