私は、今ユーザーがサインアップ後に承認メールが送られるようにしたいと考えています。しかし、ターミナルでは動いているのですが、実際にメールが送られていない状態にあります。もしわかる方がいらしたら、教えて頂きたいです。
terminal
1Rendered admin_mailer/new_guider_waiting_for_approval.html.erb within layouts/mailer (1.5ms) 2 Rendered admin_mailer/new_guider_waiting_for_approval.text.erb within layouts/mailer (0.7ms) 3 4AdminMailer#new_guider_waiting_for_approval: processed outbound mail in 781.9ms 5 6Sent mail to #{@guider.email} (2362.0ms) 7Date: Wed, 09 Oct 2019 10:35:46 +0900 8From: chancetochance2018@gmail.com 9To: #{@guider.email} 10Message-ID: <5d9d39721b57c_2c013fd792c40488197b5@77777777-no-MacBook-Air.local.mail> 11Subject: New User Awaiting Admin Approval 12Mime-Version: 1.0 13Content-Type: multipart/alternative; 14 boundary="--==_mimepart_5d9d3972bbdc_2c013fd792c477777777"; 15 charset=UTF-8 16Content-Transfer-Encoding: 7bit 17 18 19----==_mimepart_5d9d3972bbdc_2c013fd792c4048819620 20Content-Type: text/plain; 21 charset=UTF-8 22Content-Transfer-Encoding: 7bit 23 24<p>chancetochance2018@gmail.com has registered to join your site!</p> 25 <p>An admin can approve this registration by visiting the website and editing the user</p> 26 27----==_mimepart_5d9d3972bbdc_2c013fd792c4048819620 28Content-Type: text/html; 29 charset=UTF-8 30Content-Transfer-Encoding: 7bit 31 32<html> 33 <body> 34 <p>chancetochance2018@gmail.com has registered to join your site!</p> 35 <p>An admin can approve this registration by visiting the website and editing the user</p> 36 </body> 37</html> 38 39----==_mimepart_5d9d3972bbdc_2c013fd792c477777777--
application_mailer.rb
mailer
1class ApplicationMailer < ActionMailer::Base 2 default from: "chancetochance2018@gmail.com" 3 layout 'mailer' 4end 5
admin_mailer.rb
mailer
1class AdminMailer < ApplicationMailer 2 default from: 'chancetochance2018@gmail.com' 3 layout 'mailer' 4 5 def new_guider_waiting_for_approval(guider) 6 @guider = guider 7 mail( 8 from: '<chancetochance2018@gmail.com>', 9 to: '<#{@guider.email}>', 10 subject: 'New User Awaiting Admin Approval' 11 ) 12 end 13end
guider.rb
model
1 after_create :send_admin_mail 2 def send_admin_mail 3 AdminMailer.new_guider_waiting_for_approval(self).deliver_now 4 end 5 6 def active_for_authentication? 7 super && approved? 8 end 9 10 def inactive_message 11 approved? ? super : :not_approved 12 end
application_controller.b
controller
1def configure_permitted_parameters 2 devise_parameter_sanitizer.permit(:sign_up, keys: [:nickname, :accepted, :name, :approved]) 3 end
guider_controller.rb
controller
1def index 2 if params[:approved] == "false" 3 @guiders = Guider.where(approved: false) 4 else 5 @guiders = Guider.all 6 end 7end
view/plan/index.html.erb
view
1<table> 2 <% @guiders.each do |guider| %> 3 <tr> 4 <td><%= guider.email %> 5 <td><%= guider.approved %> 6 <td><%= link_to "Edit", edit_guider_path(guider) %> 7 </tr> 8 <% end %> 9</table>
new_guider_waiting_for_approval.html.erb
view
1<p><%= @guider.email %> has registered to join your site!</p> 2 <p>An admin can approve this registration by visiting the website and editing the user</p>
new_guider_waiting_for_approval.text.erb
view
1<p><%= @guider.email %> has registered to join your site!</p> 2 <p>An admin can approve this registration by visiting the website and editing the user</p>
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/10/09 14:10