質問編集履歴
1
該当ソースにしました
test
CHANGED
File without changes
|
test
CHANGED
@@ -32,7 +32,51 @@
|
|
32
32
|
|
33
33
|
詳しくはこちらのものをClneしてください。
|
34
34
|
|
35
|
+
class SessionsController < ApplicationController
|
36
|
+
|
37
|
+
def new
|
38
|
+
|
39
|
+
redirect_to new_item_path if logged_in?
|
40
|
+
|
41
|
+
end
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
def create
|
46
|
+
|
47
|
+
binding.pry
|
48
|
+
|
49
|
+
@user = User.find_by(email: params[:session][:email].downcase)
|
50
|
+
|
51
|
+
if @user && @user.authenticate(params[:session][:password])
|
52
|
+
|
53
|
+
session[:user_id] = @user.id
|
54
|
+
|
55
|
+
flash[:info] = "logged in as #{@user.name}"
|
56
|
+
|
57
|
+
redirect_to @user
|
58
|
+
|
59
|
+
else
|
60
|
+
|
35
|
-
h
|
61
|
+
flash[:danger] = 'invalid email/password combination'
|
62
|
+
|
63
|
+
render 'new'
|
64
|
+
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
68
|
+
|
69
|
+
|
70
|
+
|
71
|
+
def destroy
|
72
|
+
|
73
|
+
session[:user_id] = nil
|
74
|
+
|
75
|
+
redirect_to root_path
|
76
|
+
|
77
|
+
end
|
78
|
+
|
79
|
+
end
|
36
80
|
|
37
81
|
```
|
38
82
|
|