質問編集履歴
1
呼び出す側のコードを足しましたm(_ _)m
test
CHANGED
File without changes
|
test
CHANGED
@@ -10,6 +10,8 @@
|
|
10
10
|
|
11
11
|
|
12
12
|
|
13
|
+
model
|
14
|
+
|
13
15
|
```
|
14
16
|
|
15
17
|
def redirect_back_or(default)
|
@@ -17,6 +19,36 @@
|
|
17
19
|
redirect_to(session[:forwarding_url] || default)
|
18
20
|
|
19
21
|
session.delete(:forwarding_url)
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
```
|
26
|
+
|
27
|
+
|
28
|
+
|
29
|
+
controller
|
30
|
+
|
31
|
+
```
|
32
|
+
|
33
|
+
def create
|
34
|
+
|
35
|
+
user = User.find_by(email: params[:session][:email].downcase)
|
36
|
+
|
37
|
+
if user && user.authenticate(params[:session][:password])
|
38
|
+
|
39
|
+
log_in user
|
40
|
+
|
41
|
+
params[:session][:remember_me] == '1' ? remember(user) : forget(user)
|
42
|
+
|
43
|
+
redirect_back_or user
|
44
|
+
|
45
|
+
else
|
46
|
+
|
47
|
+
flash.now[:danger] = 'Invalid email/password combination'
|
48
|
+
|
49
|
+
render 'new'
|
50
|
+
|
51
|
+
end
|
20
52
|
|
21
53
|
end
|
22
54
|
|