質問編集履歴
1
sessions_controller.tbファイルを追記しました!
test
CHANGED
File without changes
|
test
CHANGED
@@ -432,6 +432,56 @@
|
|
432
432
|
|
433
433
|
|
434
434
|
|
435
|
+
controllers/sessions_controller.rb
|
436
|
+
|
437
|
+
```class SessionsController < ApplicationController
|
438
|
+
|
439
|
+
def new
|
440
|
+
|
441
|
+
end
|
442
|
+
|
443
|
+
|
444
|
+
|
445
|
+
def create
|
446
|
+
|
447
|
+
user = User.find_by(email: params[:session][:email].downcase)
|
448
|
+
|
449
|
+
if user && user.authenticate(params[:session][:password])
|
450
|
+
|
451
|
+
log_in user
|
452
|
+
|
453
|
+
params[:session][:remember_me] == '1' ? remember(user) : forget(user)
|
454
|
+
|
455
|
+
remember user
|
456
|
+
|
457
|
+
redirect_to user
|
458
|
+
|
459
|
+
else
|
460
|
+
|
461
|
+
flash.now[:danger] = 'invalid email/password combination'
|
462
|
+
|
463
|
+
render 'new'
|
464
|
+
|
465
|
+
end
|
466
|
+
|
467
|
+
end
|
468
|
+
|
469
|
+
|
470
|
+
|
471
|
+
def destroy
|
472
|
+
|
473
|
+
log_out if logged_in?
|
474
|
+
|
475
|
+
redirect_to root_url
|
476
|
+
|
477
|
+
end
|
478
|
+
|
479
|
+
end
|
480
|
+
|
481
|
+
```
|
482
|
+
|
483
|
+
|
484
|
+
|
435
485
|
####使用しているツール
|
436
486
|
|
437
487
|
AWS、cloud9、ruby5.1.6
|