質問編集履歴

2

再度、エラーを足しました。

2020/03/01 10:54

投稿

helo
helo

スコア36

test CHANGED
File without changes
test CHANGED
@@ -18,6 +18,8 @@
18
18
 
19
19
  NoMethodError in PasswordResetsController#create
20
20
 
21
+
22
+
21
23
  undefined method `reset_sent_at=' for #<User:0x000000000e4480a0> Did you mean? reset_token=
22
24
 
23
25
 
@@ -31,6 +33,18 @@
31
33
  end
32
34
 
33
35
 
36
+
37
+ @user = User.find_by(email: params[:password_reset][:email].downcase)
38
+
39
+ if @user
40
+
41
+ @user.create_reset_digest
42
+
43
+ @user.send_password_reset_email
44
+
45
+ flash[:info] = "Email sent with password reset instructions"
46
+
47
+ redirect_to root_url
34
48
 
35
49
 
36
50
 

1

一部修正しました。

2020/03/01 10:54

投稿

helo
helo

スコア36

test CHANGED
File without changes
test CHANGED
@@ -32,32 +32,6 @@
32
32
 
33
33
 
34
34
 
35
- $ rails test のエラー
36
-
37
-
38
-
39
- ERROR["test_password_reset", UserMailerTest, 4.0363923001568764], ETA: 00:00:02
40
-
41
- test_password_reset#UserMailerTest (4.04s)
42
-
43
- ArgumentError: ArgumentError: wrong number of arguments (given 0, expected 1)
44
-
45
- app/mailers/user_mailer.rb:18:in `password_reset'
46
-
47
- test/mailers/user_mailer_test.rb:19:in `block in <class:UserMailerTest>'
48
-
49
-
50
-
51
- 45/45: [=================================] 100% Time: 00:00:04, Time: 00:00:04
52
-
53
-
54
-
55
- Finished in 4.88327s
56
-
57
- 45 tests, 189 assertions, 0 failures, 1 errors, 0 skips
58
-
59
- ```
60
-
61
35
 
62
36
 
63
37
  ### 該当のソースコード
@@ -76,9 +50,9 @@
76
50
 
77
51
  self.reset_token = User.new_token
78
52
 
79
- update_attribute(:reset_digest, User.digest(reset_token))
53
+ update_attribute(:reset_digest, User.digest(reset_token))  
80
54
 
81
- update_attribute(:reset_sent_at, Time.zone.now)
55
+ update_attribute(:reset_sent_at, Time.zone.now)       
82
56
 
83
57
  end
84
58