質問するログイン新規登録

質問編集履歴

11

文章の修正

2021/07/13 23:35

投稿

macchan_0425
macchan_0425

スコア0

title CHANGED
File without changes
body CHANGED
@@ -26,7 +26,8 @@
26
26
 
27
27
  ### 該当のソースコード
28
28
 
29
+ ``` Ruby
29
- ``` goods_controller.rb
30
+ ###goods_controller.rb
30
31
  class GoodsController < ApplicationController
31
32
  def search
32
33
  if params[:keyword]
@@ -37,7 +38,8 @@
37
38
  end
38
39
 
39
40
  ```
41
+ ```Ruby
40
- ```search.html.erb
42
+ ###search.html.erb
41
43
  <h1>Rakuten search</h1>
42
44
  <div class='content'>
43
45
  <div id="search-box">
@@ -51,7 +53,8 @@
51
53
  </div>
52
54
  </div>
53
55
  ```
56
+ ```Ruby
54
- ```_good_list.html.erb
57
+ ###_good_list.html.erb
55
58
  <% if @goods.present? %>
56
59
  <% @goods.each do |good| %>
57
60
  <div class="list">
@@ -65,7 +68,8 @@
65
68
  <% end %>
66
69
  ```
67
70
 
71
+ ```Ruby
68
- ```search.html.erb
72
+ ###search.html.erb
69
73
  RakutenWebService.configure do |c|
70
74
  c.application_id = ENV["APPLICATION_ID"]
71
75
  # c.affiliate = ENV["AFFILIATE_ID"]

10

文章の修正

2021/07/13 23:35

投稿

macchan_0425
macchan_0425

スコア0

title CHANGED
File without changes
body CHANGED
@@ -78,22 +78,8 @@
78
78
  参考サイトではcontroller内で@itemsとなっていたのですが、
79
79
  viewで使用している変数が@goodsだったのでそちらに変更しています。
80
80
 
81
- 追記1:
82
- 環境変数をRWS_APPLICATION_IDに変更しました。
83
- そうするとエラーは表示されなくなりました。
84
- しかし、検索しても商品情報も表示されませんでした。
85
81
 
86
- 追記2:
87
- ターミナルを確認したところ、
88
- Cannot render console from 126.92.253.206! Allowed networks: 127.0.0.1, ::1, 127.0.0.0/127.255.255.255
89
82
 
90
- と表示されていました。
91
-
92
- config/development.rbに
93
- config.web_console.whitelisted_ips = '126.92.253.206'
94
- と記述しましたが同じような表示が出てきました。
95
-
96
-
97
83
  ###参考サイト
98
84
 
99
85
  https://freesworder.net/rakuten-api-rails/

9

誤字の訂正

2021/07/13 23:12

投稿

macchan_0425
macchan_0425

スコア0

title CHANGED
File without changes
body CHANGED
@@ -89,7 +89,7 @@
89
89
 
90
90
  と表示されていました。
91
91
 
92
- config/application.rbに
92
+ config/development.rbに
93
93
  config.web_console.whitelisted_ips = '126.92.253.206'
94
94
  と記述しましたが同じような表示が出てきました。
95
95
 

8

2021/07/13 23:09

投稿

macchan_0425
macchan_0425

スコア0

title CHANGED
File without changes
body CHANGED
@@ -1,8 +1,10 @@
1
1
  ### 前提・実現したいこと
2
2
 
3
- 現在、cloud9で楽天APIを使用して、楽天から商品を検索する機能を作成してみたのですが、
3
+ 現在勉強のために、cloud9で楽天APIを使用して、楽天から商品を検索する機能を作成してみまし
4
- 検索してみると、以下のようなエラーメッセージが発生しました。
4
+ しかし、検索してみると、以下のようなエラーメッセージが発生しました。
5
5
 
6
+ 初学者のため至らぬ点もあると思いますが、よろしくお願い致します。
7
+
6
8
  ### 発生している問題・エラーメッセージ
7
9
 
8
10
  ```
@@ -49,8 +51,7 @@
49
51
  </div>
50
52
  </div>
51
53
  ```
52
- ```
53
- _good_list.html.erb
54
+ ```_good_list.html.erb
54
55
  <% if @goods.present? %>
55
56
  <% @goods.each do |good| %>
56
57
  <div class="list">

7

追記

2021/07/13 11:11

投稿

macchan_0425
macchan_0425

スコア0

title CHANGED
File without changes
body CHANGED
@@ -77,12 +77,22 @@
77
77
  参考サイトではcontroller内で@itemsとなっていたのですが、
78
78
  viewで使用している変数が@goodsだったのでそちらに変更しています。
79
79
 
80
- 追記:
80
+ 追記
81
81
  環境変数をRWS_APPLICATION_IDに変更しました。
82
82
  そうするとエラーは表示されなくなりました。
83
83
  しかし、検索しても商品情報も表示されませんでした。
84
84
 
85
+ 追記2:
86
+ ターミナルを確認したところ、
87
+ Cannot render console from 126.92.253.206! Allowed networks: 127.0.0.1, ::1, 127.0.0.0/127.255.255.255
85
88
 
89
+ と表示されていました。
90
+
91
+ config/application.rbに
92
+ config.web_console.whitelisted_ips = '126.92.253.206'
93
+ と記述しましたが同じような表示が出てきました。
94
+
95
+
86
96
  ###参考サイト
87
97
 
88
98
  https://freesworder.net/rakuten-api-rails/

6

2021/07/13 10:29

投稿

macchan_0425
macchan_0425

スコア0

title CHANGED
File without changes
body CHANGED
@@ -79,7 +79,8 @@
79
79
 
80
80
  追記:
81
81
  環境変数をRWS_APPLICATION_IDに変更しました。
82
+ そうするとエラーは表示されなくなりました。
82
- そうするとエラーは表示されないのですが、検索しても商品情報も表示されませんでした。
83
+ しかし、検索しても商品情報も表示されませんでした。
83
84
 
84
85
 
85
86
  ###参考サイト

5

文章の変更

2021/07/13 09:03

投稿

macchan_0425
macchan_0425

スコア0

title CHANGED
File without changes
body CHANGED
@@ -77,7 +77,11 @@
77
77
  参考サイトではcontroller内で@itemsとなっていたのですが、
78
78
  viewで使用している変数が@goodsだったのでそちらに変更しています。
79
79
 
80
+ 追記:
81
+ 環境変数をRWS_APPLICATION_IDに変更しました。
82
+ そうするとエラーは表示されないのですが、検索しても商品情報も表示されませんでした。
80
83
 
84
+
81
85
  ###参考サイト
82
86
 
83
87
  https://freesworder.net/rakuten-api-rails/

4

文章の修正

2021/07/13 07:52

投稿

macchan_0425
macchan_0425

スコア0

title CHANGED
File without changes
body CHANGED
@@ -74,9 +74,9 @@
74
74
 
75
75
 
76
76
  ### 試したこと
77
+ 参考サイトではcontroller内で@itemsとなっていたのですが、
78
+ viewで使用している変数が@goodsだったのでそちらに変更しています。
77
79
 
78
- エラー文でキーワードが無効と書かれているのは分かったのですが、調べてみたのですが
79
- それらしい情報が見つからず困っています。
80
80
 
81
81
  ###参考サイト
82
82
 

3

文章を修正

2021/07/13 07:32

投稿

macchan_0425
macchan_0425

スコア0

title CHANGED
File without changes
body CHANGED
@@ -10,6 +10,16 @@
10
10
  Showing /home/ec2-user/environment/rakutensearch/app/views/goods/_good_list.html.erb where line #2 raised:
11
11
 
12
12
  keyword is not valid
13
+
14
+ <% if @goods.present? %>
15
+ <% @goods.each do |good| %> ←ここでエラー
16
+ <div class="list">
17
+ <% if good.image_url %>
18
+ <%= link_to (image_tag(good.image_url, style: "width: 70px;height: 100px;display: inline-block;")), good.url %>
19
+ <% end %>
20
+
21
+
22
+
13
23
  ```
14
24
 
15
25
  ### 該当のソースコード

2

文章の変更

2021/07/13 07:23

投稿

macchan_0425
macchan_0425

スコア0

title CHANGED
File without changes
body CHANGED
@@ -40,54 +40,29 @@
40
40
  </div>
41
41
  ```
42
42
  ```
43
+ _good_list.html.erb
44
+ <% if @goods.present? %>
43
- <h1>Rakuten search</h1>
45
+ <% @goods.each do |good| %>
44
- <div class='content'>
46
+ <div class="list">
45
- <div id="search-box">
47
+ <% if good.image_url %>
46
- <%= form_tag('/', method: :get) do %>
47
- <%= text_field_tag :good, "", id: "good_search", name: "keyword", placeholder: "キーワードを打ち込んでください", style: "width: 200px; "%><button title="検索" type="submit">検索</button>
48
+ <%= link_to (image_tag(good.image_url, style: "width: 70px;height: 100px;display: inline-block;")), good.url %>
48
- <% end %>
49
+ <% end %>
50
+
51
+ <%= good.title %>
49
- </div>
52
+ </div>
50
- <h2>検索結果</h2>
51
- <div id='good_list'>
52
- <%= render partial: 'good_list' %>
53
- </div>
53
+ <% end %>
54
- </div>
54
+ <% end %>
55
55
  ```
56
56
 
57
57
  ```search.html.erb
58
- <h1>Rakuten search</h1>
59
- <div class='content'>
60
- <div id="search-box">
61
- <%= form_tag('/', method: :get) do %>
62
- <%= text_field_tag :good, "", id: "good_search", name: "keyword", placeholder: "キーワードを打ち込んでください", style: "width: 200px; "%><button title="検索" type="submit">検索</button>
63
- <% end %>
64
- </div>
65
- <h2>検索結果</h2>
66
- <div id='good_list'>
67
- <%= render partial: 'good_list' %>
68
- </div>
69
- </div>
70
- ```
71
- ```
72
- <h1>Rakuten search</h1>
73
- <div class='content'>
74
- <div id="search-box">
75
- <%= form_tag('/', method: :get) do %>
76
- <%= text_field_tag :good, "", id: "good_search", name: "keyword", placeholder: "キーワードを打ち込んでください", style: "width: 200px; "%><button title="検索" type="submit">検索</button>
77
- <% end %>
78
- </div>
79
- <h2>検索結果</h2>
80
- <div id='good_list'>
81
- <%= render partial: 'good_list' %>
82
- </div>
83
- </div>
84
- ```
85
- ```
86
58
  RakutenWebService.configure do |c|
87
59
  c.application_id = ENV["APPLICATION_ID"]
60
+ # c.affiliate = ENV["AFFILIATE_ID"]
61
+ # 環境変数を使用
88
62
  end
89
63
  ```
90
64
 
65
+
91
66
  ### 試したこと
92
67
 
93
68
  エラー文でキーワードが無効と書かれているのは分かったのですが、調べてみたのですが

1

文章の変更

2021/07/13 07:03

投稿

macchan_0425
macchan_0425

スコア0

title CHANGED
File without changes
body CHANGED
@@ -14,18 +14,17 @@
14
14
 
15
15
  ### 該当のソースコード
16
16
 
17
- ```goods_controller.rb
17
+ ``` goods_controller.rb
18
18
  class GoodsController < ApplicationController
19
19
  def search
20
20
  if params[:keyword]
21
21
  @goods = RakutenWebService::Ichiba::Item.search(keyword: params[:keyword])
22
-
22
+
23
23
  end
24
24
  end
25
25
  end
26
26
 
27
27
  ```
28
-
29
28
  ```search.html.erb
30
29
  <h1>Rakuten search</h1>
31
30
  <div class='content'>
@@ -40,56 +39,7 @@
40
39
  </div>
41
40
  </div>
42
41
  ```
43
- ```_good_list.html.erb
44
- <% if @goods.present? %>
45
- <% @goods.each do |good| %>
46
- <div class="list">
47
- <% if good.image_url %>
48
- <%= link_to (image_tag(good.image_url, style: "width: 70px;height: 100px;display: inline-block;")), good.url %>
49
- <% end %>
50
-
51
- <%= good.title %>
52
- </div>
53
- <% end %>
54
- <% end %>
55
42
  ```
56
- ```
57
- ソースコード
58
- ```
59
-
60
- ### 試したこと
61
-
62
- ここに問題に対して試したことを記載してください。
63
-
64
- ### 補足情報(FW/ツールのバージョンなど)
65
-
66
- ここにより詳細な情報を記載してください。### 前提・実現したいこと
67
-
68
- 現在、cloud9でcloud9で楽天APIを使用して、検索欄を作成してみたのですが、
69
- 検索してみると、以下のようなエラーメッセージが発生しました。
70
-
71
- ### 発生している問題・エラーメッセージ
72
-
73
- ```
74
- RakutenWebService::WrongParameter in Goods#search
75
- Showing /home/ec2-user/environment/rakutensearch/app/views/goods/_good_list.html.erb where line #2 raised:
76
-
77
- keyword is not valid
78
- ```
79
-
80
- ### 該当のソースコード
81
-
82
- ``` goods_controller.rb
83
- ```
84
-
85
- ### 該当のソースコード
86
-
87
- ``` goods_controller.rb
88
- class GoodsController < ApplicationController
89
- def search
90
- if params[:keyword]
91
- @goods = RakutenWebService::Ich
92
- ```search.html.erb
93
43
  <h1>Rakuten search</h1>
94
44
  <div class='content'>
95
45
  <div id="search-box">
@@ -103,29 +53,8 @@
103
53
  </div>
104
54
  </div>
105
55
  ```
106
- ```
107
- <h1>Rakuten search</h1>
108
- <div class='content'>
109
- <div id="search-box">
110
- <%= form_tag('/', method: :get) do %>
111
- <%= text_field_tag :good, "", id: "good_search", name: "keyword", placeholder: "キーワードを打ち込んでください", style: "width: 200px; "%><button title="検索" type="submit">検索</button>
112
- <% end %>
113
- </div>
114
- <h2>検索結果</h2>
115
- <div id='good_list'>
116
- <%= render partial: 'good_list' %>
117
- </div>
118
- </div>
119
- ```
120
56
 
121
- ```search.html
57
+ ```search.html.erb
122
- ### 試したこと
123
-
124
- ここに問題に対して試したことを記載してください。
125
-
126
- ### 補足情報(FW/ツールのバージョンなど)
127
-
128
- ここにより詳細な情報を記載してください。.erb
129
58
  <h1>Rakuten search</h1>
130
59
  <div class='content'>
131
60
  <div id="search-box">