在 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