質問編集履歴
3
コードの編集
test
CHANGED
File without changes
|
test
CHANGED
@@ -280,42 +280,8 @@
|
|
280
280
|
|
281
281
|
|
282
282
|
|
283
|
-
|
284
|
-
|
285
283
|
```views
|
286
284
|
|
287
|
-
<h2>Edit Account</h2>
|
288
|
-
|
289
|
-
<h5>アカウントの編集</h5>
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
<div>
|
294
|
-
|
295
|
-
<%= form_with model: current_user, local: true do |f|%>
|
296
|
-
|
297
|
-
<%= f.label :name %>
|
298
|
-
|
299
|
-
<%= f.text_area :name, autofocus: true %>
|
300
|
-
|
301
|
-
<%= f.submit "Update", class: 'btn'%>
|
302
|
-
|
303
|
-
<% end %>
|
304
|
-
|
305
|
-
</div>
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
<%= link_to "アカウントを削除する", current_user, method: :delete %>
|
310
|
-
|
311
|
-
<%= link_to "マイページに戻る", :back %>
|
312
|
-
|
313
|
-
```
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
```views
|
318
|
-
|
319
285
|
<h2>Sign up</h2>
|
320
286
|
|
321
287
|
|
2
コードの編集
test
CHANGED
File without changes
|
test
CHANGED
@@ -8,9 +8,19 @@
|
|
8
8
|
|
9
9
|
|
10
10
|
|
11
|
+
private
|
12
|
+
|
13
|
+
def user_params
|
14
|
+
|
15
|
+
params.require(:user).permit(:name) *エラー箇所
|
16
|
+
|
17
|
+
end
|
18
|
+
|
19
|
+
|
20
|
+
|
11
21
|
Request parameters
|
12
22
|
|
13
|
-
{"_method"=>"delete", "authenticity_token"=>"云々", "controller"=>"users", "action"=>"destroy", "id"=>"
|
23
|
+
{"_method"=>"delete", "authenticity_token"=>"云々", "controller"=>"users", "action"=>"destroy", "id"=>"2"}
|
14
24
|
|
15
25
|
```
|
16
26
|
|
@@ -26,13 +36,27 @@
|
|
26
36
|
|
27
37
|
devise_for :users
|
28
38
|
|
29
|
-
root to: "
|
39
|
+
root to: "posts#index"
|
30
|
-
|
31
|
-
|
32
|
-
|
40
|
+
|
41
|
+
|
42
|
+
|
33
|
-
resources :users, only: [:
|
43
|
+
resources :users, only: [:show, :edit, :update, :destroy]
|
34
|
-
|
44
|
+
|
35
|
-
resources :friends, only: [:
|
45
|
+
resources :friends, only: [:create, :destroy]
|
46
|
+
|
47
|
+
resources :posts, only: [:index, :new, :create]
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
resources :users do
|
52
|
+
|
53
|
+
member do
|
54
|
+
|
55
|
+
get :following, :followers
|
56
|
+
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
36
60
|
|
37
61
|
end
|
38
62
|
|
@@ -76,7 +100,49 @@
|
|
76
100
|
|
77
101
|
|
78
102
|
|
79
|
-
has_many :
|
103
|
+
has_many :posts
|
104
|
+
|
105
|
+
has_many :active_friends, class_name: "Friend",
|
106
|
+
|
107
|
+
foreign_key: "follower_id",
|
108
|
+
|
109
|
+
dependent: :destroy
|
110
|
+
|
111
|
+
has_many :passive_friends, class_name: "Friend",
|
112
|
+
|
113
|
+
foreign_key: "followed_id",
|
114
|
+
|
115
|
+
dependent: :destroy
|
116
|
+
|
117
|
+
|
118
|
+
|
119
|
+
has_many :following, through: :active_friends, source: :followed
|
120
|
+
|
121
|
+
has_many :followers, through: :passive_friends, source: :follower
|
122
|
+
|
123
|
+
|
124
|
+
|
125
|
+
def follow(other_user)
|
126
|
+
|
127
|
+
following << other_user
|
128
|
+
|
129
|
+
end
|
130
|
+
|
131
|
+
|
132
|
+
|
133
|
+
def unfollow(other_user)
|
134
|
+
|
135
|
+
active_friends.find_by(followed_id: other_user.id).destroy
|
136
|
+
|
137
|
+
end
|
138
|
+
|
139
|
+
|
140
|
+
|
141
|
+
def following?(other_user)
|
142
|
+
|
143
|
+
following.include?(other_user)
|
144
|
+
|
145
|
+
end
|
80
146
|
|
81
147
|
|
82
148
|
|
@@ -92,7 +158,9 @@
|
|
92
158
|
|
93
159
|
class UsersController < ApplicationController
|
94
160
|
|
95
|
-
def
|
161
|
+
def show
|
162
|
+
|
163
|
+
@user = User.find(params[:id])
|
96
164
|
|
97
165
|
end
|
98
166
|
|
@@ -122,8 +190,6 @@
|
|
122
190
|
|
123
191
|
def destroy
|
124
192
|
|
125
|
-
User.find(params[:id]).destroy
|
126
|
-
|
127
193
|
if current_user.destroy(user_params)
|
128
194
|
|
129
195
|
redirect_to root_path
|
@@ -138,6 +204,34 @@
|
|
138
204
|
|
139
205
|
|
140
206
|
|
207
|
+
def following
|
208
|
+
|
209
|
+
@title = "Following"
|
210
|
+
|
211
|
+
@user = User.find(params[:id])
|
212
|
+
|
213
|
+
@users = @user.following
|
214
|
+
|
215
|
+
render 'show_follow'
|
216
|
+
|
217
|
+
end
|
218
|
+
|
219
|
+
|
220
|
+
|
221
|
+
def followers
|
222
|
+
|
223
|
+
@title = "Followers"
|
224
|
+
|
225
|
+
@user = User.find(params[:id])
|
226
|
+
|
227
|
+
@users = @user.followers
|
228
|
+
|
229
|
+
render 'show_follow'
|
230
|
+
|
231
|
+
end
|
232
|
+
|
233
|
+
|
234
|
+
|
141
235
|
private
|
142
236
|
|
143
237
|
def user_params
|
@@ -152,77 +246,145 @@
|
|
152
246
|
|
153
247
|
|
154
248
|
|
249
|
+
|
250
|
+
|
155
251
|
```views
|
156
252
|
|
253
|
+
<h2>Edit Account</h2>
|
254
|
+
|
157
|
-
<h
|
255
|
+
<h5>アカウントの編集</h5>
|
256
|
+
|
257
|
+
|
258
|
+
|
158
|
-
|
259
|
+
<div>
|
159
|
-
|
160
|
-
|
260
|
+
|
161
|
-
<%= form_with model: current_user, local: true do |f|%>
|
261
|
+
<%= form_with model: current_user, local: true do |f|%>
|
162
|
-
|
163
|
-
|
262
|
+
|
164
|
-
|
165
|
-
<ul class='lists-right'>
|
166
|
-
|
167
|
-
<li><%= link_to current_user.name, "#", class: "user-name" %></li>
|
168
|
-
|
169
|
-
<li><%= link_to 'ログアウト', destroy_user_session_path, method: :delete, class: "logout" %></li>
|
170
|
-
|
171
|
-
</ul>
|
172
|
-
|
173
|
-
<% el
|
263
|
+
<%= f.label :name %>
|
264
|
+
|
174
|
-
|
265
|
+
<%= f.text_area :name, autofocus: true %>
|
266
|
+
|
175
|
-
<u
|
267
|
+
<%= f.submit "Update", class: 'btn'%>
|
176
|
-
|
177
|
-
<li><%= link_to 'ログイン', new_user_session_path, class: "login" %></li>
|
178
|
-
|
179
|
-
<li><%= link_to '新規登録', new_user_registration_path, class: "sign-up" %></li>
|
180
|
-
|
181
|
-
</ul>
|
182
268
|
|
183
269
|
<% end %>
|
184
270
|
|
271
|
+
</div>
|
272
|
+
|
273
|
+
|
274
|
+
|
275
|
+
<%= link_to "アカウントを削除する", current_user, method: :delete %>
|
276
|
+
|
277
|
+
<%= link_to "マイページに戻る", :back %>
|
278
|
+
|
279
|
+
```
|
280
|
+
|
281
|
+
|
282
|
+
|
283
|
+
|
284
|
+
|
285
|
+
```views
|
286
|
+
|
287
|
+
<h2>Edit Account</h2>
|
288
|
+
|
289
|
+
<h5>アカウントの編集</h5>
|
290
|
+
|
291
|
+
|
292
|
+
|
293
|
+
<div>
|
294
|
+
|
295
|
+
<%= form_with model: current_user, local: true do |f|%>
|
296
|
+
|
297
|
+
<%= f.label :name %>
|
298
|
+
|
299
|
+
<%= f.text_area :name, autofocus: true %>
|
300
|
+
|
301
|
+
<%= f.submit "Update", class: 'btn'%>
|
302
|
+
|
303
|
+
<% end %>
|
304
|
+
|
305
|
+
</div>
|
306
|
+
|
307
|
+
|
308
|
+
|
309
|
+
<%= link_to "アカウントを削除する", current_user, method: :delete %>
|
310
|
+
|
311
|
+
<%= link_to "マイページに戻る", :back %>
|
312
|
+
|
313
|
+
```
|
314
|
+
|
315
|
+
|
316
|
+
|
317
|
+
```views
|
318
|
+
|
319
|
+
<h2>Sign up</h2>
|
320
|
+
|
321
|
+
|
322
|
+
|
323
|
+
<%= form_with model: @user, url: user_registration_path, class: 'registration-main', local: true do |f| %>
|
324
|
+
|
325
|
+
<%= render "devise/shared/error_messages", resource: resource %>
|
326
|
+
|
327
|
+
|
328
|
+
|
329
|
+
<div class="field">
|
330
|
+
|
331
|
+
<%= f.label :name %><br />
|
332
|
+
|
333
|
+
<%= f.text_area :name, autofocus: true, autocomplete: "name" %>
|
334
|
+
|
335
|
+
</div>
|
336
|
+
|
337
|
+
|
338
|
+
|
339
|
+
<div class="field">
|
340
|
+
|
341
|
+
<%= f.label :email %><br />
|
342
|
+
|
343
|
+
<%= f.email_field :email, autofocus: true, autocomplete: "email" %>
|
344
|
+
|
345
|
+
</div>
|
346
|
+
|
347
|
+
|
348
|
+
|
349
|
+
<div class="field">
|
350
|
+
|
351
|
+
<%= f.label :password %>
|
352
|
+
|
353
|
+
<% if @minimum_password_length %>
|
354
|
+
|
355
|
+
<em>(<%= @minimum_password_length %> characters minimum)</em>
|
356
|
+
|
357
|
+
<% end %><br />
|
358
|
+
|
359
|
+
<%= f.password_field :password, autocomplete: "new-password" %>
|
360
|
+
|
361
|
+
</div>
|
362
|
+
|
363
|
+
|
364
|
+
|
365
|
+
<div class="field">
|
366
|
+
|
367
|
+
<%= f.label :password_confirmation %><br />
|
368
|
+
|
369
|
+
<%= f.password_field :password_confirmation, autocomplete: "new-password" %>
|
370
|
+
|
371
|
+
</div>
|
372
|
+
|
373
|
+
|
374
|
+
|
375
|
+
<div class="actions">
|
376
|
+
|
377
|
+
<%= f.submit "Sign up" %>
|
378
|
+
|
379
|
+
</div>
|
380
|
+
|
185
381
|
<% end %>
|
186
382
|
|
187
383
|
|
188
384
|
|
189
|
-
<div>
|
190
|
-
|
191
|
-
<%= link_to "ユーザー情報編集", edit_user_path(current_user) %>
|
192
|
-
|
193
|
-
</div>
|
194
|
-
|
195
|
-
```
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
```views
|
200
|
-
|
201
|
-
<h2>Edit Account</h2>
|
202
|
-
|
203
|
-
<h5>アカウントの編集</h5>
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
<div>
|
208
|
-
|
209
|
-
<%= form_with model: current_user, local: true do |f|%>
|
210
|
-
|
211
|
-
<%= f.label :name %>
|
212
|
-
|
213
|
-
<%= f.text_area :name, autofocus: true %>
|
214
|
-
|
215
|
-
|
385
|
+
<%= render "devise/shared/links" %>
|
216
|
-
|
217
|
-
|
386
|
+
|
218
|
-
|
219
|
-
|
387
|
+
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
<%= link_to "アカウントを削除する", current_user, method: :delete %>
|
224
|
-
|
225
|
-
<%= link_to "マイページに戻る", :back, class: 'btn'%>
|
226
388
|
|
227
389
|
```
|
228
390
|
|
@@ -231,3 +393,13 @@
|
|
231
393
|
### 補足情報(FW/ツールのバージョンなど)
|
232
394
|
|
233
395
|
以前削除の件で解決したかに思われましたが、実際は解決していなかったようです。
|
396
|
+
|
397
|
+
エラーが出るタイミングとしてはuserを削除するタイミングです。
|
398
|
+
|
399
|
+
|
400
|
+
|
401
|
+
request_parameterに:nameがないのが気になるのですが、エラーに関係あるでしょうか?
|
402
|
+
|
403
|
+
|
404
|
+
|
405
|
+
エラー解決のためレビューのほどよろしくお願い致します。
|
1
問題解決していなかった
test
CHANGED
File without changes
|
test
CHANGED
@@ -230,8 +230,4 @@
|
|
230
230
|
|
231
231
|
### 補足情報(FW/ツールのバージョンなど)
|
232
232
|
|
233
|
-
アカウントを削除するボタンを押すと、エラー画面が出ている一方で、DB上ではアカウントの削除に成功しています。
|
234
|
-
|
235
|
-
いったい中でどのようなことが起きているのでしょうか?
|
236
|
-
|
237
|
-
|
233
|
+
以前削除の件で解決したかに思われましたが、実際は解決していなかったようです。
|