当我刷新页面时,我收到以下错误消息:
ActionController::RoutingError (No route matches {:action=>"value", :controller=>"round"}):
app/views/surveys/survey.html.erb:28:in `block in _app_views_surveys_survey_html_erb___3955880096442191391_70175035205180'
app/views/surveys/survey.html.erb:22:in `_app_views_surveys_survey_html_erb___3955880096442191391_70175035205180'
app/controllers/surveys_controller.rb:16:in `block (2 levels) in survey'
app/controllers/surveys_controller.rb:14:in `survey'
Rendered /Users/pitosalas/.rvm/gems/ruby-1.9.3-p194@repeatsurvey/gems/actionpack-3.2.8/lib/action_dispatch/middleware/templates/rescues/routing_error.erb within rescues/layout (0.5ms)
我很困惑。为什么引用program_participant_round_value_path导致该路由丢失?
这是我的路线档案:
root to: 'programs#index'
resources :programs do
resources :participants do
get 'survey' => 'surveys#survey'
end
resources :questions
resources :rounds
member do
get 'report' => 'reports#report'
end
end
resources :program do
resources :participant do
resources :round do
put :value
end
end
end
这是相关的佣金路线:
program_participant_round_value PUT /program/:program_id/participant/:participant_id/round/:round_id/value(.:format) round#value
我有一个控制器动作轮#值。
以下是该观点的相关部分:
<%= content_tag :table do %>
<%= content_tag :thead do %>
<% 5.times do |q| %>
<%= content_tag :th, "1" %>
<% end %>
<% end %>
<% form_tag program_participant_round_value_path do %>
<%= content_tag :tbody do %>
<%= render partial: 'surveys/value', collection: @values %>
<% end %>
<%= submit_tag "Save" %>
<% end %>
<% end %>
谢谢!
答案 0 :(得分:1)
您的program_participant_round_value
路线需要多个参数:
:program_id
:participant_id
:round_id
调用program_participant_round_value_path
帮助程序时,您需要为这些参数提供值:
program_participant_round_value_path(program_id: @program, participant_id: @participant, round_id: @round)
当然,变量名称等可能会略有不同,具体取决于您在控制器中定义它们的方式。