質問編集履歴
3
ソースコードの追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -195,3 +195,265 @@
|
|
195
195
|
|
196
196
|
|
197
197
|
失礼な点があるかもしれませんがどうぞ宜しくおねがい致します。
|
198
|
+
|
199
|
+
|
200
|
+
|
201
|
+
|
202
|
+
|
203
|
+
### 追記
|
204
|
+
|
205
|
+
registrations_controller.rb
|
206
|
+
|
207
|
+
```
|
208
|
+
|
209
|
+
# frozen_string_literal: true
|
210
|
+
|
211
|
+
|
212
|
+
|
213
|
+
class Users::RegistrationsController < Devise::RegistrationsController
|
214
|
+
|
215
|
+
# before_action :configure_sign_up_params, only: [:create]
|
216
|
+
|
217
|
+
# before_action :configure_account_update_params, only: [:update]
|
218
|
+
|
219
|
+
|
220
|
+
|
221
|
+
# GET /resource/sign_up
|
222
|
+
|
223
|
+
def new
|
224
|
+
|
225
|
+
super
|
226
|
+
|
227
|
+
@user = User.
|
228
|
+
|
229
|
+
end
|
230
|
+
|
231
|
+
|
232
|
+
|
233
|
+
# POST /resource
|
234
|
+
|
235
|
+
def create
|
236
|
+
|
237
|
+
super
|
238
|
+
|
239
|
+
@user = User.new(user_params)
|
240
|
+
|
241
|
+
if @user.save
|
242
|
+
|
243
|
+
flash[:notice] = "会員登録完了あなたは#{@user.id}人目のサービス利用者なので貢献度を#{@user.id}ポイントプレゼントします(´・ω・`)"
|
244
|
+
|
245
|
+
@imalevel = 1
|
246
|
+
|
247
|
+
@imalevel += @user.id
|
248
|
+
|
249
|
+
redirect_to("/")
|
250
|
+
|
251
|
+
else
|
252
|
+
|
253
|
+
flash[:alert] = "会員登録失敗"
|
254
|
+
|
255
|
+
render action: :new
|
256
|
+
|
257
|
+
end
|
258
|
+
|
259
|
+
end
|
260
|
+
|
261
|
+
# GET /resource/edit
|
262
|
+
|
263
|
+
def edit
|
264
|
+
|
265
|
+
super
|
266
|
+
|
267
|
+
end
|
268
|
+
|
269
|
+
# PUT /resource
|
270
|
+
|
271
|
+
def update
|
272
|
+
|
273
|
+
super
|
274
|
+
|
275
|
+
end
|
276
|
+
|
277
|
+
|
278
|
+
|
279
|
+
# DELETE /resource
|
280
|
+
|
281
|
+
def destroy
|
282
|
+
|
283
|
+
super
|
284
|
+
|
285
|
+
end
|
286
|
+
|
287
|
+
|
288
|
+
|
289
|
+
# GET /resource/cancel
|
290
|
+
|
291
|
+
# Forces the session data which is usually expired after sign
|
292
|
+
|
293
|
+
# in to be expired now. This is useful if the user wants to
|
294
|
+
|
295
|
+
# cancel oauth signing in/up in the middle of the process,
|
296
|
+
|
297
|
+
# removing all OAuth session data.
|
298
|
+
|
299
|
+
# def cancel
|
300
|
+
|
301
|
+
# super
|
302
|
+
|
303
|
+
# end
|
304
|
+
|
305
|
+
#
|
306
|
+
|
307
|
+
# protected
|
308
|
+
|
309
|
+
|
310
|
+
|
311
|
+
# If you have extra params to permit, append them to the sanitizer.
|
312
|
+
|
313
|
+
# def configure_sign_up_params
|
314
|
+
|
315
|
+
# devise_parameter_sanitizer.permit(:sign_up, keys: [:attribute])
|
316
|
+
|
317
|
+
# end
|
318
|
+
|
319
|
+
#
|
320
|
+
|
321
|
+
# If you have extra params to permit, append them to the sanitizer.
|
322
|
+
|
323
|
+
# def configure_account_update_params
|
324
|
+
|
325
|
+
# devise_parameter_sanitizer.permit(:account_update, keys: [:attribute])
|
326
|
+
|
327
|
+
# end
|
328
|
+
|
329
|
+
#
|
330
|
+
|
331
|
+
# The path used after sign up.
|
332
|
+
|
333
|
+
# def after_sign_up_path_for(resource)
|
334
|
+
|
335
|
+
# super(resource)
|
336
|
+
|
337
|
+
# end
|
338
|
+
|
339
|
+
#
|
340
|
+
|
341
|
+
# The path used after sign up for inactive accounts.
|
342
|
+
|
343
|
+
# def after_inactive_sign_up_path_for(resource)
|
344
|
+
|
345
|
+
# super(resource)
|
346
|
+
|
347
|
+
# end
|
348
|
+
|
349
|
+
end
|
350
|
+
|
351
|
+
```
|
352
|
+
|
353
|
+
これでhttp://localhost:3000/sinkiにアクセスすると発生するエラーメッセージ↓
|
354
|
+
|
355
|
+
```
|
356
|
+
|
357
|
+
SyntaxError
|
358
|
+
|
359
|
+
C:/Users/r1148/butube/app/controllers/users/registrations_controller.rb:71: syntax error, unexpected end-of-input, expecting end
|
360
|
+
|
361
|
+
```
|
362
|
+
|
363
|
+
|
364
|
+
|
365
|
+
念のためroutes.rb↓
|
366
|
+
|
367
|
+
```
|
368
|
+
|
369
|
+
Rails.application.routes.draw do
|
370
|
+
|
371
|
+
devise_for :users
|
372
|
+
|
373
|
+
get '/' => 'home#top'
|
374
|
+
|
375
|
+
devise_scope :user do
|
376
|
+
|
377
|
+
get 'login' => 'devise/sessions#new'
|
378
|
+
|
379
|
+
post 'login' => 'devise/sessions#create'
|
380
|
+
|
381
|
+
delete 'logout' => 'devise/sessions#destroy'
|
382
|
+
|
383
|
+
get 'sinki' => 'users/registrations#new'
|
384
|
+
|
385
|
+
post 'sinki' => 'devise/registrations#create'
|
386
|
+
|
387
|
+
get 'signup/cancel' => 'devise_invitable/registrations#cancel'
|
388
|
+
|
389
|
+
get 'user' => 'devise_invitable/registrations#edit'
|
390
|
+
|
391
|
+
patch 'user' => 'devise_invitable/registrations#update'
|
392
|
+
|
393
|
+
put 'user' => 'devise_invitable/registrations#update'
|
394
|
+
|
395
|
+
delete 'user' => 'devise_invitable/registrations#destroy'
|
396
|
+
|
397
|
+
get 'password' => 'devise/passwords#new'
|
398
|
+
|
399
|
+
post 'password' => 'devise/passwords#create'
|
400
|
+
|
401
|
+
get 'password/edit' => 'devise/passwords#edit'
|
402
|
+
|
403
|
+
patch 'password' => 'devise/passwords#update'
|
404
|
+
|
405
|
+
put 'password' => 'devise/passwords#update'
|
406
|
+
|
407
|
+
end
|
408
|
+
|
409
|
+
get 'you' => 'home#you'
|
410
|
+
|
411
|
+
post 'seikou' => 'home#seikou'
|
412
|
+
|
413
|
+
get 'kensaku' => 'video#kensaku'
|
414
|
+
|
415
|
+
get 'post' => 'post#new'
|
416
|
+
|
417
|
+
post 'arigatou' => 'post#create'
|
418
|
+
|
419
|
+
get 'index' => 'video#index'
|
420
|
+
|
421
|
+
get 'ionamata' => 'video#toukou'
|
422
|
+
|
423
|
+
post 'yosi!' => 'video#create'
|
424
|
+
|
425
|
+
get 'riyoukiyaku' => 'video#riyoukiyaku'
|
426
|
+
|
427
|
+
post 'kekka' => 'video#kekka'
|
428
|
+
|
429
|
+
get 'kesu' => 'home#kesu'
|
430
|
+
|
431
|
+
get 'kesu/taikai' => 'home#destroy'
|
432
|
+
|
433
|
+
resources :show do
|
434
|
+
|
435
|
+
member do
|
436
|
+
|
437
|
+
get 'star'
|
438
|
+
|
439
|
+
end
|
440
|
+
|
441
|
+
end
|
442
|
+
|
443
|
+
post 'hosi' => 'video#hosi'
|
444
|
+
|
445
|
+
resources :show do
|
446
|
+
|
447
|
+
member do
|
448
|
+
|
449
|
+
get 'komento'
|
450
|
+
|
451
|
+
end
|
452
|
+
|
453
|
+
end
|
454
|
+
|
455
|
+
get '/:id' => 'video#show'
|
456
|
+
|
457
|
+
end
|
458
|
+
|
459
|
+
```
|
2
繁栄したコードの追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
### 前提・実現したいこと
|
2
2
|
|
3
|
-
Ruby on railsでページを表示させたいです。
|
3
|
+
Ruby on railsで「/sinki」に新規登録ページを表示させたいです。
|
4
4
|
|
5
5
|
gem deviseを使用しています。
|
6
6
|
|
@@ -14,7 +14,7 @@
|
|
14
14
|
|
15
15
|
### エラーメッセージ
|
16
16
|
|
17
|
-
![](
|
17
|
+
![](ead6a1dd2920c613185d17ab3f108604.png)
|
18
18
|
|
19
19
|
```
|
20
20
|
|
@@ -110,7 +110,7 @@
|
|
110
110
|
|
111
111
|
end
|
112
112
|
|
113
|
-
|
113
|
+
end
|
114
114
|
|
115
115
|
# GET /resource/cancel
|
116
116
|
|
@@ -184,11 +184,11 @@
|
|
184
184
|
|
185
185
|
Windows 10 home 64ビット
|
186
186
|
|
187
|
-
ruby 2.
|
187
|
+
ruby 2.6.6
|
188
188
|
|
189
|
-
Ruby on rails
|
189
|
+
Ruby on rails 6.0.3.1
|
190
190
|
|
191
|
-
PostgreSQL 1
|
191
|
+
PostgreSQL 13beta1
|
192
192
|
|
193
193
|
テキストエディタ Atom
|
194
194
|
|
1
追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,20 +1,26 @@
|
|
1
1
|
### 前提・実現したいこと
|
2
2
|
|
3
|
-
Ruby on railsで
|
3
|
+
Ruby on railsでページを表示させたいです。
|
4
4
|
|
5
|
-
|
5
|
+
gem deviseを使用しています。
|
6
6
|
|
7
7
|
|
8
8
|
|
9
9
|
### 発生している問題
|
10
10
|
|
11
|
+
エラーメッセージが表示されてページを閲覧できません。
|
12
|
+
|
11
13
|
|
12
14
|
|
13
15
|
### エラーメッセージ
|
14
16
|
|
17
|
+
![](fe11f5a6e31992c0965f5f95a529c87e.png)
|
18
|
+
|
15
19
|
```
|
16
20
|
|
17
|
-
|
21
|
+
SyntaxError
|
22
|
+
|
23
|
+
C:/Users/r1148/butube/app/controllers/users/registrations_controller.rb:70: syntax error, unexpected end-of-input, expecting end
|
18
24
|
|
19
25
|
```
|
20
26
|
|
@@ -22,11 +28,153 @@
|
|
22
28
|
|
23
29
|
### 該当のソースコード
|
24
30
|
|
31
|
+
registrations_controller.rb
|
32
|
+
|
33
|
+
```
|
34
|
+
|
35
|
+
# frozen_string_literal: true
|
25
36
|
|
26
37
|
|
27
38
|
|
39
|
+
class Users::RegistrationsController < Devise::RegistrationsController
|
28
40
|
|
41
|
+
# before_action :configure_sign_up_params, only: [:create]
|
42
|
+
|
43
|
+
# before_action :configure_account_update_params, only: [:update]
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
# GET /resource/sign_up
|
48
|
+
|
49
|
+
def new
|
50
|
+
|
51
|
+
super
|
52
|
+
|
53
|
+
@user = User.
|
54
|
+
|
55
|
+
end
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
# POST /resource
|
60
|
+
|
61
|
+
def create
|
62
|
+
|
63
|
+
super
|
64
|
+
|
65
|
+
@user = User.new(user_params)
|
66
|
+
|
67
|
+
if @user.save
|
68
|
+
|
69
|
+
flash[:notice] = "会員登録完了あなたは#{@user.id}人目のサービス利用者なので貢献度を#{@user.id}ポイントプレゼントします(´・ω・`)"
|
70
|
+
|
71
|
+
@imalevel = 1
|
72
|
+
|
73
|
+
@imalevel += @user.id
|
74
|
+
|
75
|
+
redirect_to("/")
|
76
|
+
|
77
|
+
else
|
78
|
+
|
79
|
+
flash[:alert] = "会員登録失敗"
|
80
|
+
|
81
|
+
render action: :new
|
82
|
+
|
83
|
+
end
|
84
|
+
|
85
|
+
end
|
86
|
+
|
87
|
+
# GET /resource/edit
|
88
|
+
|
89
|
+
def edit
|
90
|
+
|
91
|
+
super
|
92
|
+
|
93
|
+
end
|
94
|
+
|
95
|
+
# PUT /resource
|
96
|
+
|
97
|
+
def update
|
98
|
+
|
99
|
+
super
|
100
|
+
|
101
|
+
end
|
102
|
+
|
103
|
+
|
104
|
+
|
105
|
+
# DELETE /resource
|
106
|
+
|
107
|
+
def destroy
|
108
|
+
|
109
|
+
super
|
110
|
+
|
111
|
+
end
|
112
|
+
|
113
|
+
|
114
|
+
|
115
|
+
# GET /resource/cancel
|
116
|
+
|
117
|
+
# Forces the session data which is usually expired after sign
|
118
|
+
|
119
|
+
# in to be expired now. This is useful if the user wants to
|
120
|
+
|
121
|
+
# cancel oauth signing in/up in the middle of the process,
|
122
|
+
|
123
|
+
# removing all OAuth session data.
|
124
|
+
|
125
|
+
# def cancel
|
126
|
+
|
29
|
-
#
|
127
|
+
# super
|
128
|
+
|
129
|
+
# end
|
130
|
+
|
131
|
+
#
|
132
|
+
|
133
|
+
# protected
|
134
|
+
|
135
|
+
|
136
|
+
|
137
|
+
# If you have extra params to permit, append them to the sanitizer.
|
138
|
+
|
139
|
+
# def configure_sign_up_params
|
140
|
+
|
141
|
+
# devise_parameter_sanitizer.permit(:sign_up, keys: [:attribute])
|
142
|
+
|
143
|
+
# end
|
144
|
+
|
145
|
+
#
|
146
|
+
|
147
|
+
# If you have extra params to permit, append them to the sanitizer.
|
148
|
+
|
149
|
+
# def configure_account_update_params
|
150
|
+
|
151
|
+
# devise_parameter_sanitizer.permit(:account_update, keys: [:attribute])
|
152
|
+
|
153
|
+
# end
|
154
|
+
|
155
|
+
#
|
156
|
+
|
157
|
+
# The path used after sign up.
|
158
|
+
|
159
|
+
# def after_sign_up_path_for(resource)
|
160
|
+
|
161
|
+
# super(resource)
|
162
|
+
|
163
|
+
# end
|
164
|
+
|
165
|
+
#
|
166
|
+
|
167
|
+
# The path used after sign up for inactive accounts.
|
168
|
+
|
169
|
+
# def after_inactive_sign_up_path_for(resource)
|
170
|
+
|
171
|
+
# super(resource)
|
172
|
+
|
173
|
+
# end
|
174
|
+
|
175
|
+
|
176
|
+
|
177
|
+
```
|
30
178
|
|
31
179
|
|
32
180
|
|