質問編集履歴
3
rooms index.html.erb を追加
title
CHANGED
File without changes
|
body
CHANGED
@@ -182,7 +182,25 @@
|
|
182
182
|
|
183
183
|
コード
|
184
184
|
```
|
185
|
+
rooms index.html.erb ↓
|
185
186
|
|
187
|
+
```<div class="container">
|
188
|
+
<h1><%= link_to "#{current_user.username}さんのページ", user_path(@user) %></h1>
|
189
|
+
<h3>Chatroom一覧</h3>
|
190
|
+
<div>
|
191
|
+
<ul>
|
192
|
+
<% @rooms.each do |room| %>
|
193
|
+
<li><%= link_to "ROOM#{room.id}", room_path(room.id, @user.id) %></li>
|
194
|
+
<% end %>
|
195
|
+
</ul>
|
196
|
+
</div>
|
197
|
+
<h3>お気に入り</h3>
|
198
|
+
<% if current_user.try(:admin?) %>
|
199
|
+
<%= link_to "管理者画面", admin_users_path, class: 'btn' %>
|
200
|
+
<% end %>
|
201
|
+
</div>
|
202
|
+
コード
|
203
|
+
```
|
186
204
|
|
187
205
|
schemaファイルにはimageカラムがあるのに何故エラーが出ているのでしょうか?
|
188
206
|
|
2
エラーコードの追加、各コードを<code>で括りました。
title
CHANGED
File without changes
|
body
CHANGED
@@ -38,10 +38,13 @@
|
|
38
38
|
|
39
39
|
以下が関係していると感じているコードです。
|
40
40
|
|
41
|
-
<code>
|
42
41
|
|
42
|
+
|
43
43
|
rooms_controller.rb ↓
|
44
44
|
|
45
|
+
|
46
|
+
```rooms_controller.rb ↓
|
47
|
+
|
45
48
|
class RoomsController < ApplicationController
|
46
49
|
|
47
50
|
def index
|
@@ -58,11 +61,17 @@
|
|
58
61
|
|
59
62
|
</code>
|
60
63
|
|
61
|
-
|
64
|
+
コード
|
65
|
+
```
|
62
66
|
|
67
|
+
|
68
|
+
|
69
|
+
|
63
70
|
routes.rb ↓
|
64
71
|
|
72
|
+
|
73
|
+
|
65
|
-
Rails.application.routes.draw do
|
74
|
+
```Rails.application.routes.draw do
|
66
75
|
namespace :admin do
|
67
76
|
resources :users
|
68
77
|
end
|
@@ -82,15 +91,15 @@
|
|
82
91
|
resources :users, :only => [:index, :show, :edit, :destroy]
|
83
92
|
|
84
93
|
end
|
94
|
+
コード
|
95
|
+
```
|
85
96
|
|
86
|
-
</code>
|
87
97
|
|
88
98
|
|
89
|
-
<code>
|
90
99
|
|
91
100
|
users_controller.rb ↓
|
92
101
|
|
93
|
-
class UsersController < ApplicationController
|
102
|
+
```class UsersController < ApplicationController
|
94
103
|
before_action :authenticate_user!
|
95
104
|
|
96
105
|
def show
|
@@ -117,14 +126,13 @@
|
|
117
126
|
end
|
118
127
|
|
119
128
|
end
|
129
|
+
コード
|
130
|
+
```
|
120
131
|
|
121
|
-
</code>
|
122
132
|
|
123
|
-
<code>
|
124
|
-
|
125
133
|
rooms show.html.erb ↓
|
126
134
|
|
127
|
-
<div class="chat-room">
|
135
|
+
```<div class="chat-room">
|
128
136
|
<h1>Chat room</h1>
|
129
137
|
<div id='messages' data-room_id="<%= @room.id %>">
|
130
138
|
<%= render @messages %>
|
@@ -136,13 +144,12 @@
|
|
136
144
|
<%= label_tag :content, 'Say something' %>
|
137
145
|
</div>
|
138
146
|
|
139
|
-
|
147
|
+
コード
|
148
|
+
```
|
140
149
|
|
141
|
-
<code>
|
142
|
-
|
143
150
|
_messages.erb ↓
|
144
151
|
|
145
|
-
<div class='message'>
|
152
|
+
```<div class='message'>
|
146
153
|
<% if @user.image.present? %>
|
147
154
|
<%= image_tag(@user.image.thumb100.url) %>
|
148
155
|
<% else %>
|
@@ -150,14 +157,14 @@
|
|
150
157
|
<% end %>
|
151
158
|
<p><%= "#{message.user.email}: #{message.content}" %></p>
|
152
159
|
</div>
|
160
|
+
コード
|
161
|
+
```
|
153
162
|
|
154
|
-
</code>
|
155
163
|
|
156
|
-
<code>
|
157
164
|
|
158
165
|
schema.rb ↓
|
159
166
|
|
160
|
-
create_table "users", force: :cascade do |t|
|
167
|
+
```create_table "users", force: :cascade do |t|
|
161
168
|
t.string "email", default: "", null: false
|
162
169
|
t.string "encrypted_password", default: "", null: false
|
163
170
|
t.string "reset_password_token"
|
@@ -173,8 +180,10 @@
|
|
173
180
|
t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true
|
174
181
|
end
|
175
182
|
|
176
|
-
|
183
|
+
コード
|
184
|
+
```
|
177
185
|
|
186
|
+
|
178
187
|
schemaファイルにはimageカラムがあるのに何故エラーが出ているのでしょうか?
|
179
188
|
|
180
189
|
ご助力お願いします。
|
1
エラーコードの追加、各コードを<code>で括りました。
title
CHANGED
File without changes
|
body
CHANGED
@@ -2,12 +2,44 @@
|
|
2
2
|
|
3
3
|
チャット画面で投稿する際に以下のエラーがでてしまい、画面リロードをしないと文字が表示されなくなりました。
|
4
4
|
|
5
|
-
|
5
|
+
Finished "/cable/" [WebSocket] for 192.168.33.1 at 2019-11-29 04:22:12 +0100
|
6
|
+
RoomChannel stopped streaming from room_channel_
|
7
|
+
Started GET "/cable" for 192.168.33.1 at 2019-11-29 04:22:12 +0100
|
8
|
+
Cannot render console from 192.168.33.1! Allowed networks: 127.0.0.0/127.255.255.255, ::1
|
9
|
+
Started GET "/cable/" [WebSocket] for 192.168.33.1 at 2019-11-29 04:22:12 +0100
|
10
|
+
Successfully upgraded to WebSocket (REQUEST_METHOD: GET, HTTP_CONNECTION: Upgrade, HTTP_UPGRADE: websocket)
|
11
|
+
User Load (0.2ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? ORDER BY "users"."id" ASC LIMIT ? [["id", 1], ["LIMIT", 1]]
|
12
|
+
↳ app/channels/application_cable/connection.rb:12:in `find_verified_user'
|
13
|
+
User Load (0.2ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT ? [["id", 1], ["LIMIT", 1]]
|
14
|
+
↳ app/channels/application_cable/connection.rb:12:in `find_verified_user'
|
15
|
+
Registered connection (Z2lkOi8vY2hhdGFwcC9Vc2VyLzE)
|
16
|
+
RoomChannel is transmitting the subscription confirmation
|
17
|
+
RoomChannel is streaming from room_channel_1
|
18
|
+
RoomChannel#speak({"message"=>"i have no idea"})
|
19
|
+
(0.1ms) begin transaction
|
20
|
+
↳ app/channels/room_channel.rb:12:in `speak'
|
21
|
+
User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT ? [["id", 1], ["LIMIT", 1]]
|
22
|
+
↳ app/channels/room_channel.rb:12:in `speak'
|
23
|
+
Room Load (0.1ms) SELECT "rooms".* FROM "rooms" WHERE "rooms"."id" = ? LIMIT ? [["id", 1], ["LIMIT", 1]]
|
24
|
+
↳ app/channels/room_channel.rb:12:in `speak'
|
25
|
+
Message Create (2.8ms) INSERT INTO "messages" ("content", "created_at", "updated_at", "user_id", "room_id") VALUES (?, ?, ?, ?, ?) [["content", "i have no idea"], ["created_at", "2019-11-29 03:22:23.549954"], ["updated_at", "2019-11-29 03:22:23.549954"], ["user_id", 1], ["room_id", 1]]
|
26
|
+
↳ app/channels/room_channel.rb:12:in `speak'
|
27
|
+
(7.4ms) commit transaction
|
28
|
+
↳ app/channels/room_channel.rb:12:in `speak'
|
29
|
+
[ActiveJob] Enqueued MessageBroadcastJob (Job ID: 57f40449-6e0e-41c7-8dbc-efd67e142aac) to Async(default) with arguments: #<GlobalID:0x00007f2910d615b0 @uri=#<URI::GID gid://chatapp/Message/59>>
|
30
|
+
Message Load (0.2ms) SELECT "messages".* FROM "messages" WHERE "messages"."id" = ? LIMIT ? [["id", 59], ["LIMIT", 1]]
|
31
|
+
[ActiveJob] [MessageBroadcastJob] [57f40449-6e0e-41c7-8dbc-efd67e142aac] Performing MessageBroadcastJob (Job ID: 57f40449-6e0e-41c7-8dbc-efd67e142aac) from Async(default) enqueued at 2019-11-29T03:22:23Z with arguments: #<GlobalID:0x00007f2928034708 @uri=#<URI::GID gid://chatapp/Message/59>>
|
32
|
+
[ActiveJob] [MessageBroadcastJob] [57f40449-6e0e-41c7-8dbc-efd67e142aac] Rendered messages/_message.html.erb (Duration: 6.9ms | Allocations: 1487)
|
33
|
+
[ActiveJob] [MessageBroadcastJob] [57f40449-6e0e-41c7-8dbc-efd67e142aac] Error performing MessageBroadcastJob (Job ID: 57f40449-6e0e-41c7-8dbc-efd67e142aac) from Async(default) in 8.56ms: ActionView::Template::Error (undefined method `image' for nil:NilClass):
|
34
|
+
/home/vagrant/environment/chatapp/app/views/messages/_message.html.erb:2:in `_app_views_messages__message_html_erb__1902079675368871319_69907370882620'
|
35
|
+
/home/vagrant/.rbenv/versions/2.6.4/lib/ruby/gems/2.6.0/gems/actionview-6.0.1/lib/action_view/base.rb:274:in `_run'
|
6
36
|
|
7
37
|
ネットで調べ、controllerを変更したり、deviseの仕様についても調べましたが,解決しませんでした。
|
8
38
|
|
9
39
|
以下が関係していると感じているコードです。
|
10
40
|
|
41
|
+
<code>
|
42
|
+
|
11
43
|
rooms_controller.rb ↓
|
12
44
|
|
13
45
|
class RoomsController < ApplicationController
|
@@ -24,6 +56,10 @@
|
|
24
56
|
end
|
25
57
|
end
|
26
58
|
|
59
|
+
</code>
|
60
|
+
|
61
|
+
<code>
|
62
|
+
|
27
63
|
routes.rb ↓
|
28
64
|
|
29
65
|
Rails.application.routes.draw do
|
@@ -32,8 +68,7 @@
|
|
32
68
|
end
|
33
69
|
|
34
70
|
devise_for :users, :controllers => {
|
35
|
-
registrations: 'users/registrations'
|
71
|
+
registrations: 'users/registrations'}
|
36
|
-
}
|
37
72
|
|
38
73
|
|
39
74
|
root to: 'top#show'
|
@@ -48,6 +83,11 @@
|
|
48
83
|
|
49
84
|
end
|
50
85
|
|
86
|
+
</code>
|
87
|
+
|
88
|
+
|
89
|
+
<code>
|
90
|
+
|
51
91
|
users_controller.rb ↓
|
52
92
|
|
53
93
|
class UsersController < ApplicationController
|
@@ -78,6 +118,10 @@
|
|
78
118
|
|
79
119
|
end
|
80
120
|
|
121
|
+
</code>
|
122
|
+
|
123
|
+
<code>
|
124
|
+
|
81
125
|
rooms show.html.erb ↓
|
82
126
|
|
83
127
|
<div class="chat-room">
|
@@ -92,6 +136,10 @@
|
|
92
136
|
<%= label_tag :content, 'Say something' %>
|
93
137
|
</div>
|
94
138
|
|
139
|
+
</code>
|
140
|
+
|
141
|
+
<code>
|
142
|
+
|
95
143
|
_messages.erb ↓
|
96
144
|
|
97
145
|
<div class='message'>
|
@@ -103,6 +151,10 @@
|
|
103
151
|
<p><%= "#{message.user.email}: #{message.content}" %></p>
|
104
152
|
</div>
|
105
153
|
|
154
|
+
</code>
|
155
|
+
|
156
|
+
<code>
|
157
|
+
|
106
158
|
schema.rb ↓
|
107
159
|
|
108
160
|
create_table "users", force: :cascade do |t|
|
@@ -121,6 +173,8 @@
|
|
121
173
|
t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true
|
122
174
|
end
|
123
175
|
|
176
|
+
</code>
|
177
|
+
|
124
178
|
schemaファイルにはimageカラムがあるのに何故エラーが出ているのでしょうか?
|
125
179
|
|
126
180
|
ご助力お願いします。
|