質問編集履歴
2
ログとrails consoleの追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -125,3 +125,167 @@
|
|
125
125
|
</div>
|
126
126
|
|
127
127
|
```
|
128
|
+
|
129
|
+
|
130
|
+
|
131
|
+
追記:エラーログとrails consoleでの値の入力確認
|
132
|
+
|
133
|
+
```
|
134
|
+
|
135
|
+
Started GET "/posts/1" for IPアドレス at 2020-09-20 04:14:24 +0000
|
136
|
+
|
137
|
+
Cannot render console from IPアドレス! Allowed networks: 127.0.0.1, ::1, 127.0.0.0/127.255.255.255
|
138
|
+
|
139
|
+
Processing by PostsController#show as HTML
|
140
|
+
|
141
|
+
Parameters: {"id"=>"1"}
|
142
|
+
|
143
|
+
[1m[36mUser Load (1.1ms)[0m [1m[34m
|
144
|
+
|
145
|
+
SELECT
|
146
|
+
|
147
|
+
`users`. *
|
148
|
+
|
149
|
+
FROM
|
150
|
+
|
151
|
+
`users`
|
152
|
+
|
153
|
+
WHERE
|
154
|
+
|
155
|
+
`users`.`id` = 1 LIMIT 1[0m
|
156
|
+
|
157
|
+
↳ app/controllers/application_controller.rb:6
|
158
|
+
|
159
|
+
[1m[36mPost Load (1.0ms)[0m [1m[34m
|
160
|
+
|
161
|
+
SELECT
|
162
|
+
|
163
|
+
`posts`. *
|
164
|
+
|
165
|
+
FROM
|
166
|
+
|
167
|
+
`posts`
|
168
|
+
|
169
|
+
WHERE
|
170
|
+
|
171
|
+
`posts`.`id` = 1 LIMIT 1[0m
|
172
|
+
|
173
|
+
↳ app/controllers/posts_controller.rb:15
|
174
|
+
|
175
|
+
[1m[36mCACHE User Load (0.0ms)[0m [1m[34mSELECT `users`.* FROM `users` WHERE `users`.`id` = 1 LIMIT 1[0m [["id", 1], ["LIMIT", 1]]
|
176
|
+
|
177
|
+
↳ app/controllers/posts_controller.rb:16
|
178
|
+
|
179
|
+
[1m[35m (1.0ms)[0m [1m[34m
|
180
|
+
|
181
|
+
SELECT
|
182
|
+
|
183
|
+
COUNT( * )
|
184
|
+
|
185
|
+
FROM
|
186
|
+
|
187
|
+
`likes`
|
188
|
+
|
189
|
+
WHERE
|
190
|
+
|
191
|
+
`likes`.`post_id` = 1[0m
|
192
|
+
|
193
|
+
↳ app/controllers/posts_controller.rb:17
|
194
|
+
|
195
|
+
Rendering posts/show.html.erb within layouts/application
|
196
|
+
|
197
|
+
[1m[36mLike Load (1.0ms)[0m [1m[34m
|
198
|
+
|
199
|
+
SELECT
|
200
|
+
|
201
|
+
`likes`. *
|
202
|
+
|
203
|
+
FROM
|
204
|
+
|
205
|
+
`likes`
|
206
|
+
|
207
|
+
WHERE
|
208
|
+
|
209
|
+
`likes`.`user_id` = 1
|
210
|
+
|
211
|
+
AND `likes`.`post_id` = 1 LIMIT 1[0m
|
212
|
+
|
213
|
+
↳ app/views/posts/show.html.erb:26
|
214
|
+
|
215
|
+
[1m[36mComment Exists (1.0ms)[0m [1m[34m
|
216
|
+
|
217
|
+
SELECT
|
218
|
+
|
219
|
+
1 AS one
|
220
|
+
|
221
|
+
FROM
|
222
|
+
|
223
|
+
`comments`
|
224
|
+
|
225
|
+
WHERE
|
226
|
+
|
227
|
+
`comments`.`post_id` = 1 LIMIT 1[0m
|
228
|
+
|
229
|
+
↳ app/views/posts/show.html.erb:43
|
230
|
+
|
231
|
+
[1m[36mComment Load (1.3ms)[0m [1m[34m
|
232
|
+
|
233
|
+
SELECT
|
234
|
+
|
235
|
+
`comments`. *
|
236
|
+
|
237
|
+
FROM
|
238
|
+
|
239
|
+
`comments`
|
240
|
+
|
241
|
+
WHERE
|
242
|
+
|
243
|
+
`comments`.`post_id` = 1[0m
|
244
|
+
|
245
|
+
↳ app/views/posts/show.html.erb:47
|
246
|
+
|
247
|
+
Rendered collection of comments/_comment.html.erb [8 times] (34.7ms)
|
248
|
+
|
249
|
+
Rendered posts/show.html.erb within layouts/application (111.3ms)
|
250
|
+
|
251
|
+
Completed 500 Internal Server Error in 236ms (ActiveRecord: 6.5ms)
|
252
|
+
|
253
|
+
ActionView::Template::Error (no implicit conversion of nil into String):
|
254
|
+
|
255
|
+
2: <p><%= simple_format(comment.comment) %></p>
|
256
|
+
|
257
|
+
3: <br/>
|
258
|
+
|
259
|
+
4:
|
260
|
+
|
261
|
+
5: <%= content_tag(:iframe, 'map', src:'https://www.google.com/maps/embed/v1/place?key=APIキー&q=' + comment.address, width: '100%', height: 400, frameborder: 0) %>
|
262
|
+
|
263
|
+
6:
|
264
|
+
|
265
|
+
7: <br/>
|
266
|
+
|
267
|
+
8: <div class="p-comment__bottomLine">
|
268
|
+
|
269
|
+
app/views/comments/_comment.html.erb:5:in `+'
|
270
|
+
|
271
|
+
app/views/comments/_comment.html.erb:5:in `_app_views_comments__comment_html_erb__95375582550985352_69815137906500'
|
272
|
+
|
273
|
+
app/views/posts/show.html.erb:47:in `_app_views_posts_show_html_erb__991977752560510296_69815134793420'
|
274
|
+
|
275
|
+
```
|
276
|
+
|
277
|
+
```
|
278
|
+
|
279
|
+
$ rails console
|
280
|
+
|
281
|
+
#<Comment id: 10, post_id: 1, name: "uuu", comment: "iii", user_id: 1, created_at: "2020-09-20 04:12:40", updated_at: "2020-09-20 04:12:40", address: "okinawa">]>
|
282
|
+
|
283
|
+
$ comment = Comment.find(10)
|
284
|
+
|
285
|
+
$ comment.address
|
286
|
+
|
287
|
+
=> "okinawa"
|
288
|
+
|
289
|
+
なので値は入っているかと思います
|
290
|
+
|
291
|
+
```
|
1
comment.html.erb追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -81,3 +81,47 @@
|
|
81
81
|
すみませんが解決のためアドバイスを頂けないでしょうか。
|
82
82
|
|
83
83
|
よろしくお願いします。
|
84
|
+
|
85
|
+
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
追記:comment.html.erb
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
Google Mapは表示できていませんが、comment.nameやcomment.created_atなど他のcommentモデルのカラム情報は表示できています。
|
94
|
+
|
95
|
+
```
|
96
|
+
|
97
|
+
<p><%= simple_format(comment.comment) %></p>
|
98
|
+
|
99
|
+
<br/>
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
<%= content_tag(:iframe, 'map', src:'https://www.google.com/maps/embed/v1/place?key=APIキー&q=' + comment.address, width: 400, height: 200, frameborder: 0) %>
|
104
|
+
|
105
|
+
|
106
|
+
|
107
|
+
<br/>
|
108
|
+
|
109
|
+
<div class="p-comment__bottomLine">
|
110
|
+
|
111
|
+
<span><%= comment.name %></span>
|
112
|
+
|
113
|
+
<br/><br/>
|
114
|
+
|
115
|
+
<span><%= comment.created_at %></span>
|
116
|
+
|
117
|
+
<br/><br/>
|
118
|
+
|
119
|
+
<% if comment.user_id == @current_user.id %>
|
120
|
+
|
121
|
+
<%= link_to '削除', comment, method: :delete, data: { confirm: '削除してもいいですか?' }, class: 'btn btn-primary' %>
|
122
|
+
|
123
|
+
<% end %>
|
124
|
+
|
125
|
+
</div>
|
126
|
+
|
127
|
+
```
|