Rails5.1.3でWebアプリケーション制作の勉強中です。ブラウザで編集画面にアクセスしようとするとエラーがでてしまい。
解決できずにいます。ルーティングのエラーかと思いますが、自力では解決できないのでどなたか教えていただけないでしょうか?
エラー内容及び関係すると思われるコードは以下になります。
エラー内容 ActionController::UrlGenerationError in Customer::Top#index Showing /home/vagrant/chibi/chibi/app/views/customer/top/dashboard_b.html.erb where line #7 raised: No route matches {:action=>"edit", :controller=>"customer/banks", :host=>"example.com"}, missing required keys: [:id] Extracted source (around line #7): 5 <li><%= link_to 'プログラム一覧', :customer_programs %></li> 6 <li><%= link_to '受信メッセージ一覧', :customer_messages %></li> 7 <li><%= link_to '口座アカウント編集', :edit_customer_bank %></li> 8</ul>
エラー内容 ActionView::Template::Error (No route matches {:action=>"edit", :controller=>"customer/banks", :host=>"example.com"}, missing required keys: [:id]): 4: <ul class="menu"> 5: <li><%= link_to 'プログラム一覧', :customer_programs %></li> 6: <li><%= link_to '受信メッセージ一覧', :customer_messages %></li> 7: <li><%= link_to '口座アカウント編集', :edit_customer_bank %></li> 8: </ul> app/views/customer/top/dashboard_b.html.erb:7:in `_app_views_customer_top_dashboard_b_html_erb__4251273561019877823_70347071425080' app/controllers/customer/top_controller.rb:11:in `index'
app/views/customer/top/dashboard_b.html.erb <% @title = 'ダッシュボード' %> <h1><%= @title %></h1> <ul class="menu"> <li><%= link_to 'プログラム一覧', :customer_programs %></li> <li><%= link_to '受信メッセージ一覧', :customer_messages %></li> <li><%= link_to '口座アカウント編集', :edit_customer_bank %></li> </ul>
rails routes customer_banks GET /mypage/banks(.:format) customer/banks#index {:host=>"example.com"} POST /mypage/banks(.:format) customer/banks#create {:host=>"example.com"} new_customer_bank GET /mypage/banks/new(.:format) customer/banks#new {:host=>"example.com"} edit_customer_bank GET /mypage/banks/:id/edit(.:format) customer/banks#edit {:host=>"example.com"} customer_bank GET /mypage/banks/:id(.:format) customer/banks#show {:host=>"example.com"} PATCH /mypage/banks/:id(.:format) customer/banks#update {:host=>"example.com"} PUT /mypage/banks/:id(.:format) customer/banks#update {:host=>"example.com"} DELETE /mypage/banks/:id(.:format) customer/banks#destroy {:host=>"example.com"}
app/controllers/banks_controller.rb class Customer::BanksController < Customer::Base def index logger.debug customer_params @search_form = Customer::BankSearchForm.new(customer_params[:search]) @banks = @search_form.search.page(params[:page]) end def show @bank = Bank.find(params[:id]) end def new @bank_form = Customer::BankForm.new end def edit @bank_form = Customer::BankForm.new(Bank.find(params[:id])) end def create end def update end def destroy end end
関連すると思われるコードは以上です。リンク先に edit_customer_bank を記述しているのですが、エラーが出てしまいます。
new_customer_bank の登録画面は表示されるのですが、編集画面が表示できないので困っております。
:idを指定しなければいけないのかな?と思いますが、どこに、どのように記述すればいいのか見当もつきません。
どなたか解決方法を教えていただけませんでしょうか?宜しくお願いいたします。
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。