Rails5.1.3でWebアプリケーション制作の勉強をしています。ActionController::UrlGenerationError in Staff::Customers#indexのエラーが
発生してしまい解決できないので教えていただけないでしょうか?エラー内容、関連コードは以下になります。
エラー内容 ActionController::UrlGenerationError in Staff::Customers#index Showing /home/vagrant/chibi/chibi/app/views/staff/customers/index.html.erb where line #36 raised: No route matches {:action=>"individual", :controller=>"staff/customers", :host=>"chibi.example.com"}, missing required keys: [:customer_id] Extracted source (around line #36) 34 <td><%= p.sponsor1 %></td> 35 <td class="actions"> 36 <%= link_to '成績', [ :staff_customer_individual] %> | 37 <%= link_to '詳細', [ :staff, c ] %> | 38 <%= link_to '編集', [ :edit, :staff, c ] %> | 39 <%= link_to '削除', [ :staff, c ], method: :delete,
routes.rb resources :customers do get :individual get :bonus_record end
$ rails routes staff_customer_individual GET /customers/:customer_id/individual(.:format) staff/customers#individual {:host=>"chibi.example.com"}
<% @customers.each do |c| %> <% p = CustomerPresenter.new(c, self) %> <tr> <td><%= p.full_name %></td> <td><%= p.full_name_kana %></td> <td class="email"><%= p.email %></td> <td class="date"><%= p.birthday %></td> <td><%= p.gender %></td> <td><%= p.nickname %></td> <td><%= p.sponsor1 %></td> <td class="actions"> <%= link_to '成績', [ :staff_customer_individual] %> | <%= link_to '詳細', [ :staff, c ] %> | <%= link_to '編集', [ :edit, :staff, c ] %> | <%= link_to '削除', [ :staff, c ], method: :delete, data: { confirm: '本当に削除しますか?' } %> </td> </tr> <% end %>
staff/customers_controller.rb def individual render action: 'individual' end def bonus_record render action: 'bonus_record' end
individual.html.erb <% @title = '個人成績' %> <h1><%= @title %></h1> <%= link_to "タイトル状況", :staff_customer_bonus_record %><br> <%= link_to "2018年実績", :staff_eighteen %><br> <%= link_to "2019年実績", :staff_nineteen %><br> <%= link_to "2020年実績", :staff_twentie %><br> <%= link_to "2021年実績", :staff_one %><br> <div class="table-wrapper"> <div class="links"> <%= link_to 'トップ画面へ戻る', :staff_root %> </div> </div>
たぶんindex.html.erbの<%= link_to '成績', [ :staff_customer_individual] %> |の部分にcustomer_idを指定しなければ
いけないのかな?と思いますが指定の仕方がわりません。
やりたいことは「成績」をクリックしたときにindividual.html.erbの内容を表示したいのです。
どなたか教えていただけないでしょうか?宜しくお願いします。

回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2017/12/17 09:14