0

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 %>

ただし、コントローラーとルートはプログラムモデルに関連していることに注意してください(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
4

1 に答える 1

2

programs複数のリソースとして定義しているため、ルートが見つかりません。

resources :programs do

memberあなたがそれをしてあなたのようなルートを参照するとき、それはあなたの場合のパラメータをbulk_add_participants期待します。:program_id(実行rake routesしてみると、のようなパスが表示されます/programs/:program_id/bulk_add_participants。)

したがって、form_tag呼び出しはおそらく次のようになります。

<%= form_tag bulk_add_participants_program_path(@program) do %>
于 2013-02-26T21:39:25.150 に答える