Rails5.1.3でWebアプリケーション制作の勉強をしています。
単純にshowアクションで表示したいだけなのですが,長文のエラーが出てしまい解決できずにいます。
なんとなくですが、「フォーマットが無いです。」と言われているような感じですが、特別なコードを
記述しているわけでもないので原因がわかりません。
エラーコードとコードは以下になります。
エラーコード
ActionController::UnknownFormat in Customer::SpecialsController#show Customer::SpecialsController#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
special_controller.rb class Customer::SpecialsController < Customer::Base def show @customer = Customer.find_by(id: current_customer.id) special = Special.find_by(customer_id: current_customer.id) if special.count1 == 1 @special = "特A" elsif special.count2 == 1 @special = "特B" elsif special.count3 == 1 @special = "特C" elsif special.count4 == 1 @special = "特D" elsif special.count5 == 1 @special = "特E" else @spesial = "がんばろう!" end end end
special.html.erb <% @title = '料理ランキング' %> <h1><%= @title %></h1> <div class="table-wrapper"> <table class="attributes"> <tr><th colspan= "3">リクエスト</th></tr> <% p1 = CustomerPresenter.new(@customer, self) %> <tr><th>氏名</th><td><%= p1.full_name %></td></tr> <tr><th>ニックネーム</th><td><%= p1.nickname %></td></tr> <tr><th>料理</th><td><%= @special %></td></tr> <tr><th>金額</th><td>¥<%= @special %></td></tr> </table> </div> <div class="table-wrapper"> <div class="links"> <%= link_to '個人成績表画面へ戻る', :individual_customer_record %> </div> </div> <div class="table-wrapper"> <div class="links"> <%= link_to 'トップ画面へ戻る', :customer_root %> </div> </div>
コードはこんな単純なコードですが、原因がわからないエラーです。
エラーの内容がわからないのが自分のレベルの一番の問題だと思いますが、助けていただけませんでしょうか?
どなたか教えていただけないでしょうか?宜しくお願いします。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。