0
當我刷新頁面我得到這個錯誤信息:路徑規格似乎並不匹配生成的方法
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/[email protected]/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 %>
謝謝!
而這會影響它尋找的路線?奇。讓我嘗試。謝謝! – pitosalas
好的進展,但現在我得到的錯誤:沒有路由匹配{:action =>「value」,:controller =>「round」,:program => 1,:participant => 2,:round => 9}我需要對路線進行一些更改。但在我走下這條路之前,我寧願提交表單的網址看起來像./program/1/participant/2/round/3/update。你似乎知道這個東西很冷。你能給我一個指針嗎?謝謝10^6 – pitosalas
一定要將'method::put'作爲參數傳遞給'form_tag'。 –