前提・実現したいこと
ここに質問の内容を詳しく書いてください。
rubyで楽天APIを利用した検索フォームを作成しています。
検索画面までは問題なく実装できましたが、検索ボタンを押した後、下記のようなエラーメッセージが発生しました。
発生している問題・エラーメッセージ
Application ID is not defined
<tbody> <% if @items.present? %> <% @items.each do |item| %> <tr> <td><%= link_to item.name, "#{item.url}" %></td> <td align="right"><%= number_with_delimiter(item.price) %>円</td>
該当のソースコード
goods_controller.rb
class GoodsController < ApplicationController def search if params[:keyword] @items = RakutenWebService::Ichiba::Item.search(keyword: params[:keyword]) end end end
rakuten.rb
RakutenWebService.configuration do |c| # (Required) Appliction ID for your application. c.application_id = '実際は楽天IDを入力しています' # (Optional) Affiliate ID for your Rakuten account. c.affiliate_id = '' # default: nil # (Optional) # of retries to send requests when the client receives # When the number of requests in some period overcomes the limit, the endpoints will return # too many requests error. Then the client tries to retry to send the same request after a # while. c.max_retries = 3 # default: 5 # (Optional) Enable debug mode. When set true, the client streams out all HTTP requests and # responses to the standard error. c.debug = true # default: false end
search.html.erb
<%= form_tag :root, method: :get do %> <%= label_tag :keyword, 'キーワード検索' %> <%= text_field_tag 'keyword', params[:keyword] %> <%= submit_tag "検索" %> <% end %> <table> <thead> <tr> <th>商品名</th> <th>価格</th> <th>画像</th> </tr> </thead> <tbody> <% if @items.present? %> <% @items.each do |item| %> <tr> <td><%= link_to item.name, "#{item.url}" %></td> <td align="right"><%= number_with_delimiter(item.price) %>円</td> <td><%= image_tag item["smallImageUrls"][0]["imageUrl"] %></td> </tr> <% end %> <% end %> </tbody> </table>
試したこと
楽天IDを確認しましたが、間違いはなさそうでした。
Application ID is not definedで検索しましたがなかなか同じ内容のエラーが見つからず、糸口が見つからない状況です(検索の仕方が下手なのもあると思いますが、)
解決方法をご存知の方はご教授いただければ幸いです。
何卒よろしくお願い致します。
補足情報(FW/ツールのバージョンなど)
ここにより詳細な情報を記載してください。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/08/04 02:38
2019/08/04 03:15