【发布时间】:2013-02-26 21:34:56
【问题描述】:
在 app/views/participants/index.html.erb 内:
<%= 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 %>
但请注意,控制器和路由与 Program 模型相关(出于良好的 UI 原因)。我认为这可能与问题有关。当我渲染该视图时,我收到以下错误消息:
No route matches {:action=>"bulk_add_participants", :controller=>"programs"}
这很奇怪,因为在 app/controllers/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
【问题讨论】:
-
bulk_add_participants_program_url也无法识别?运行rake routes说明了这些路线?
标签: ruby-on-rails routes