質問編集履歴

2

エラー内容を追記しました。

2017/05/02 06:54

投稿

yamady
yamady

スコア176

test CHANGED
File without changes
test CHANGED
@@ -94,6 +94,74 @@
94
94
 
95
95
 
96
96
 
97
+ 下記にエラーがあるみたいです。。
98
+
99
+
100
+
101
+ (users_controller.rb)
102
+
103
+ ```Ruby
104
+
105
+ ・・・
106
+
107
+ def create
108
+
109
+ @user = User.new(user_params)
110
+
111
+ if @user.save
112
+
113
+ @user.send_activation_email
114
+
115
+ flash[:info] = "Please check your email to activate your account."
116
+
117
+ redirect_to root_url
118
+
119
+ else
120
+
121
+ render 'new'
122
+
123
+ end
124
+
125
+ end
126
+
127
+ ・・・
128
+
129
+ ```
130
+
131
+
132
+
133
+ (User.rb)
134
+
135
+ ```Ruby
136
+
137
+ ・・・
138
+
139
+ # アカウントを有効にする
140
+
141
+ def activate
142
+
143
+ update_attribute(:activated, true)
144
+
145
+ update_attribute(:activated_at, Time.zone.now)
146
+
147
+ end
148
+
149
+
150
+
151
+ # 有効化用のメールを送信する
152
+
153
+ def send_activation_email
154
+
155
+ UserMailer.account_activation(self).deliver_now
156
+
157
+ end
158
+
159
+ ・・・
160
+
161
+ ```
162
+
163
+
164
+
97
165
  何度も申し訳ありませんが、お助けくださいませ。
98
166
 
99
167
  どうぞよろしくお願いいたします。

1

エラー内容の詳細を追記しました

2017/05/02 06:54

投稿

yamady
yamady

スコア176

test CHANGED
File without changes
test CHANGED
@@ -6,13 +6,17 @@
6
6
 
7
7
  ```Ruby
8
8
 
9
+ config.action_mailer.delivery_method = :smtp
10
+
9
11
  config.action_mailer.raise_delivery_errors = true
10
12
 
11
- config.action_mailer.delivery_method = :test
13
+ config.action_mailer.perform_deliveries = true
14
+
15
+ config.action_mailer.default :charset => "utf-8"
12
16
 
13
17
  host = 'localhost:3000'
14
18
 
15
- config.action_mailer.default_url_options = { host: host, protocol: 'https' }
19
+ config.action_mailer.default_url_options = { host:'localhost', port: '3000' }
16
20
 
17
21
  ActionMailer::Base.smtp_settings = {
18
22
 
@@ -26,6 +30,8 @@
26
30
 
27
31
  :password => ENV['SENDGRID_PASSWORD'],
28
32
 
33
+ :domain => 'localhost:3000',
34
+
29
35
  :enable_starttls_auto => true
30
36
 
31
37
  }
@@ -34,4 +40,60 @@
34
40
 
35
41
 
36
42
 
37
- 上記を「development.rb」に書き加えたのですが、どうもメールが送られて気配がありません。。
43
+ 上記を「development.rb」にて設定しはずなのですが、一向に動く気配がありません。。実際の登録画面でアカウント登録をすると、下記のエラーが発生してしまいます。
44
+
45
+
46
+
47
+ Net::SMTPFatalError in UsersController#create
48
+
49
+ 550 Unauthenticated senders not allowed
50
+
51
+ Extracted source (around line #52):
52
+
53
+ ```Ruby
54
+
55
+ ・・・
56
+
57
+ # 有効化用のメールを送信する
58
+
59
+ def send_activation_email
60
+
61
+ UserMailer.account_activation(self).deliver_now
62
+
63
+ end
64
+
65
+
66
+
67
+ private
68
+
69
+
70
+
71
+ # メールアドレスをすべて小文字にする
72
+
73
+ def downcase_email
74
+
75
+ self.email = email.downcase
76
+
77
+ end
78
+
79
+
80
+
81
+ # 有効化トークンとダイジェストを作成および代入する
82
+
83
+ def create_activation_digest
84
+
85
+ self.activation_token = User.new_token
86
+
87
+ self.activation_digest = User.digest(activation_token)
88
+
89
+ end
90
+
91
+ end
92
+
93
+ ```
94
+
95
+
96
+
97
+ 何度も申し訳ありませんが、お助けくださいませ。
98
+
99
+ どうぞよろしくお願いいたします。