Rails5.1.3でWebアプリケーション制作の勉強中です。
アカウントの更新フォームで更新ボタンをクリックすると以下のエラーが出ます。
たぶん、showアクションのフォーマットが無いです。みたいなエラーだと思っていますがはっきりはわかりません。
エラー内容 ActionController::UnknownFormat in Customer::BanksController#show Customer::BanksController#show is missing a template for this request format and variant. request.formats: ["text/html"] request.variant: [] NOTE! For XHR/Ajax or API requests, this action would normally respond with 204 No Content: an empty white screen. Since you're loading it in a web browser, we assume that you expected to actually render a template, not nothing, so we're showing an error to be extra-clear. If you expect 204 No Content, carry on. That's what you'll get from an XHR or API request. Give it a shot. Extracted source (around line #53): 51 "That's what you'll get from an XHR or API request. Give it a shot." 52 53 raise ActionController::UnknownFormat, message 54 else 55 logger.info "No template found for #{self.class.name}\##{action_name}, rendering head :no_content" if logger 56 super
Started GET "/mypage/bank" for 10.0.2.2 at 2017-09-17 07:08:06 +0000 Processing by Customer::BanksController#show as HTML Parameters: {"host"=>"example.com"} Customer Load (0.5ms) SELECT `customers`.* FROM `customers` WHERE `customers `.`id` = 1 LIMIT 1 Bank Load (0.7ms) SELECT `banks`.* FROM `banks` WHERE `banks`.`customer_id` = 1 LIMIT 1 Completed 406 Not Acceptable in 54ms (ActiveRecord: 1.2ms) ActionController::UnknownFormat (Customer::BanksController#show is missing a tem plate for this request format and variant. request.formats: ["text/html"] request.variant: [] NOTE! For XHR/Ajax or API requests, this action would normally respond with 204 No Content: an empty white screen. Since you're loading it in a web browser, we assume that you expected to actually render a template, not nothing, so we're sh owing an error to be extra-clear. If you expect 204 No Content, carry on. That's what you'll get from an XHR or API request. Give it a shot.):
以下のコードでshowアクションを呼び出してしまっているため(Started GET "/mypage/bank)となってしまうのかと思います。
詳細ページは不要なので作成していないです。
url: :customer_bank と記述しているため、呼び出してしまっているのだと思いますが、update の呼び出し指定も同じなのでここが
悪さしているのかと思います。(区別して指定する方法がわかりません。)
編集画面 <% @title = '口座アカウントの編集' %> <h1><%= @title %></h1> <div id="generic-form"> <%= form_for @bank_form, as: 'form', url: :confirm_customer_bank do |f| %> <%= render 'form', f: f %> <div class="buttons"> <%= f.submit '確認画面へ進む' %> <%= link_to 'キャンセル', :customer_root %> </div> <% end %> </div>
編集内容確認画面 <% @title = '口座アカウントの更新(確認)' %> <h1><%= @title %></h1> <div id="generic-form"> <%= form_for @bank_form, as: 'form', url: :customer_bank do |f| %> <p>以下の内容で口座アカウントを更新します。よろしいですか?</p> <%= render 'confirming_form', f: f %> <div class="buttons"> <%= f.submit '更新' %> <%= f.submit '訂正', name: 'correct' %> </div> <% end %> </div>
これをupdateアクションを指定するにはどのように記述すればいいのでしょうか?GETではなくてPATCHで呼ぶようにするには
どう記述すればいいのか、それとも他のファイルの記述内容がおかしいのか、エラーコードの中から読み取ることができないので
どなたか、エラーの内容、解決方法を教えていただけないでしょうか?
宜しくお願いします。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。