質問編集履歴

1

Session_controller.rbを追加いたしました

2019/01/21 15:38

投稿

yonamine
yonamine

score11

test CHANGED
File without changes
test CHANGED
@@ -1,5 +1,71 @@
1
+ session_controller.rb
2
+
3
+ ```ruby
4
+
5
+ class SessionsController < ApplicationController
6
+
7
+ def new
8
+
9
+
10
+
11
+ end
12
+
13
+
14
+
15
+ def create
16
+
17
+
18
+
19
+ user = User.find_by(email: params[:session][:email].downcase)
20
+
21
+ if user && user.authenticate(params[:session][:password])
22
+
23
+ log_in user
24
+
25
+ params[:session][:remember_me] == '1' ? remember(user) : forget(user)
26
+
27
+ remember user
28
+
29
+ redirect_to user
30
+
31
+ else
32
+
33
+ flash.now[:danger] = "Invalid email/password combination"
34
+
35
+ render "new"
36
+
37
+ end
38
+
39
+ end
40
+
41
+
42
+
43
+ def destroy
44
+
45
+
46
+
47
+ log_out if logged_in?
48
+
49
+ redirect_to root_url
50
+
51
+ end
52
+
53
+
54
+
55
+
56
+
57
+ end
58
+
59
+
60
+
61
+ ```
62
+
63
+
64
+
1
65
  test_helpr.rb
2
66
 
67
+
68
+
3
69
  ``` ruby
4
70
 
5
71