2013-02-26 23 views
0

內部應用程序/視圖/參與者/ index.html.erb:Rails的路徑沒有找到相應的動作

<%= form_tag bulk_add_participants_program_path do %> 
    <%= wrap_control_group do %> 
    <%= text_area_tag :bulk_add_participants, :size => "60x3" %> 
    <% end %> 
    <%= submit_tag "Import Participants and Users" %> 
<% end %> 

但要注意的是,控制器和路線涉及到計劃模型和I(良好的用戶界面的原因。)認爲這可能與問題有關。當我渲染視圖我收到此錯誤信息:

No route matches {:action=>"bulk_add_participants", :controller=>"programs"} 

這是奇怪,因爲在應用程序/控制器/ programs_controller.rb:

def bulk_add_participants 
    puts "yay!" # because i am troubleshooting 
    end 

而且我的config/routes.rb文件是:

RepSurv::Application.routes.draw do 

    root to: 'programs#index' 

    devise_for :users, path_prefix: 'devise' 
    resources :users 

    resources :programs do 
    resources :participants do 
     resources :rounds do 
     get 'survey' => 'rounds#present_survey' 
     put 'survey' => 'rounds#store_survey' 
     end 
    end 
    resources :questions 
    resources :rounds 
    member do 
     get 'report' => 'reports#report' 
     get 'bulk_add_participants' 
    end 
    end 
end 

有人看到了嗎?謝謝!

resources :programs do 

當你做到這一點,引用像你bulk_add_participants一個member路線,預計在你的情況下,:program_id參數:

+0

'bulk_add_participants_program_url'也不會被認可?運行'耙路線'說有關這些路線的東西? – Kaeros 2013-02-26 21:43:48

回答

2

,因爲你有programs定義爲多個資源它沒有找到路徑。 (嘗試運行rake routes,你會看到像/programs/:program_id/bulk_add_participants的路徑。)

所以你form_tag呼叫或許應該是這樣的:

<%= form_tag bulk_add_participants_program_path(@program) do %> 
+0

謝謝!之前我被燒過了,感謝額外的設置哦! – pitosalas 2013-02-26 21:56:50

+1

不客氣。 '耙路線'是你這樣的情況下的朋友。 – 2013-02-26 21:57:40

+1

哦,但我做了多次耙路,我在路由中看到/ 1 /,並嘗試過等等。但是我的大腦並沒有將需要的參數連接到呼叫站點。頭腦不好。謝謝! – pitosalas 2013-02-26 21:59:23

相關問題