質問編集履歴
2
ログとrails consoleの追加
title
CHANGED
File without changes
|
body
CHANGED
@@ -61,4 +61,86 @@
|
|
61
61
|
<%= link_to '削除', comment, method: :delete, data: { confirm: '削除してもいいですか?' }, class: 'btn btn-primary' %>
|
62
62
|
<% end %>
|
63
63
|
</div>
|
64
|
+
```
|
65
|
+
|
66
|
+
追記:エラーログとrails consoleでの値の入力確認
|
67
|
+
```
|
68
|
+
Started GET "/posts/1" for IPアドレス at 2020-09-20 04:14:24 +0000
|
69
|
+
Cannot render console from IPアドレス! Allowed networks: 127.0.0.1, ::1, 127.0.0.0/127.255.255.255
|
70
|
+
Processing by PostsController#show as HTML
|
71
|
+
Parameters: {"id"=>"1"}
|
72
|
+
[1m[36mUser Load (1.1ms)[0m [1m[34m
|
73
|
+
SELECT
|
74
|
+
`users`. *
|
75
|
+
FROM
|
76
|
+
`users`
|
77
|
+
WHERE
|
78
|
+
`users`.`id` = 1 LIMIT 1[0m
|
79
|
+
↳ app/controllers/application_controller.rb:6
|
80
|
+
[1m[36mPost Load (1.0ms)[0m [1m[34m
|
81
|
+
SELECT
|
82
|
+
`posts`. *
|
83
|
+
FROM
|
84
|
+
`posts`
|
85
|
+
WHERE
|
86
|
+
`posts`.`id` = 1 LIMIT 1[0m
|
87
|
+
↳ app/controllers/posts_controller.rb:15
|
88
|
+
[1m[36mCACHE User Load (0.0ms)[0m [1m[34mSELECT `users`.* FROM `users` WHERE `users`.`id` = 1 LIMIT 1[0m [["id", 1], ["LIMIT", 1]]
|
89
|
+
↳ app/controllers/posts_controller.rb:16
|
90
|
+
[1m[35m (1.0ms)[0m [1m[34m
|
91
|
+
SELECT
|
92
|
+
COUNT( * )
|
93
|
+
FROM
|
94
|
+
`likes`
|
95
|
+
WHERE
|
96
|
+
`likes`.`post_id` = 1[0m
|
97
|
+
↳ app/controllers/posts_controller.rb:17
|
98
|
+
Rendering posts/show.html.erb within layouts/application
|
99
|
+
[1m[36mLike Load (1.0ms)[0m [1m[34m
|
100
|
+
SELECT
|
101
|
+
`likes`. *
|
102
|
+
FROM
|
103
|
+
`likes`
|
104
|
+
WHERE
|
105
|
+
`likes`.`user_id` = 1
|
106
|
+
AND `likes`.`post_id` = 1 LIMIT 1[0m
|
107
|
+
↳ app/views/posts/show.html.erb:26
|
108
|
+
[1m[36mComment Exists (1.0ms)[0m [1m[34m
|
109
|
+
SELECT
|
110
|
+
1 AS one
|
111
|
+
FROM
|
112
|
+
`comments`
|
113
|
+
WHERE
|
114
|
+
`comments`.`post_id` = 1 LIMIT 1[0m
|
115
|
+
↳ app/views/posts/show.html.erb:43
|
116
|
+
[1m[36mComment Load (1.3ms)[0m [1m[34m
|
117
|
+
SELECT
|
118
|
+
`comments`. *
|
119
|
+
FROM
|
120
|
+
`comments`
|
121
|
+
WHERE
|
122
|
+
`comments`.`post_id` = 1[0m
|
123
|
+
↳ app/views/posts/show.html.erb:47
|
124
|
+
Rendered collection of comments/_comment.html.erb [8 times] (34.7ms)
|
125
|
+
Rendered posts/show.html.erb within layouts/application (111.3ms)
|
126
|
+
Completed 500 Internal Server Error in 236ms (ActiveRecord: 6.5ms)
|
127
|
+
ActionView::Template::Error (no implicit conversion of nil into String):
|
128
|
+
2: <p><%= simple_format(comment.comment) %></p>
|
129
|
+
3: <br/>
|
130
|
+
4:
|
131
|
+
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) %>
|
132
|
+
6:
|
133
|
+
7: <br/>
|
134
|
+
8: <div class="p-comment__bottomLine">
|
135
|
+
app/views/comments/_comment.html.erb:5:in `+'
|
136
|
+
app/views/comments/_comment.html.erb:5:in `_app_views_comments__comment_html_erb__95375582550985352_69815137906500'
|
137
|
+
app/views/posts/show.html.erb:47:in `_app_views_posts_show_html_erb__991977752560510296_69815134793420'
|
138
|
+
```
|
139
|
+
```
|
140
|
+
$ rails console
|
141
|
+
#<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">]>
|
142
|
+
$ comment = Comment.find(10)
|
143
|
+
$ comment.address
|
144
|
+
=> "okinawa"
|
145
|
+
なので値は入っているかと思います
|
64
146
|
```
|
1
comment.html.erb追記
title
CHANGED
File without changes
|
body
CHANGED
@@ -39,4 +39,26 @@
|
|
39
39
|

|
40
40
|
|
41
41
|
すみませんが解決のためアドバイスを頂けないでしょうか。
|
42
|
-
よろしくお願いします。
|
42
|
+
よろしくお願いします。
|
43
|
+
|
44
|
+
|
45
|
+
追記:comment.html.erb
|
46
|
+
|
47
|
+
Google Mapは表示できていませんが、comment.nameやcomment.created_atなど他のcommentモデルのカラム情報は表示できています。
|
48
|
+
```
|
49
|
+
<p><%= simple_format(comment.comment) %></p>
|
50
|
+
<br/>
|
51
|
+
|
52
|
+
<%= content_tag(:iframe, 'map', src:'https://www.google.com/maps/embed/v1/place?key=APIキー&q=' + comment.address, width: 400, height: 200, frameborder: 0) %>
|
53
|
+
|
54
|
+
<br/>
|
55
|
+
<div class="p-comment__bottomLine">
|
56
|
+
<span><%= comment.name %></span>
|
57
|
+
<br/><br/>
|
58
|
+
<span><%= comment.created_at %></span>
|
59
|
+
<br/><br/>
|
60
|
+
<% if comment.user_id == @current_user.id %>
|
61
|
+
<%= link_to '削除', comment, method: :delete, data: { confirm: '削除してもいいですか?' }, class: 'btn btn-primary' %>
|
62
|
+
<% end %>
|
63
|
+
</div>
|
64
|
+
```
|