質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.50%
Ruby

Rubyはプログラミング言語のひとつで、オープンソース、オブジェクト指向のプログラミング開発に対応しています。

Ruby on Rails 4

Ruby on Rails4はRubyによって書かれたオープンソースのウェブフレームワークです。 Ruby on Railsは「設定より規約」の原則に従っており、効率的に作業を行うために再開発を行う必要をなくしてくれます。

HTML

HTMLとは、ウェブ上の文書を記述・作成するためのマークアップ言語のことです。文章の中に記述することで、文書の論理構造などを設定することができます。ハイパーリンクを設定できるハイパーテキストであり、画像・リスト・表などのデータファイルをリンクする情報に結びつけて情報を整理します。現在あるネットワーク上のほとんどのウェブページはHTMLで作成されています。

Q&A

解決済

1回答

1258閲覧

ターミナルでは動いているのですが、メールが届いていない状態にあります。

avicii

総合スコア49

Ruby

Rubyはプログラミング言語のひとつで、オープンソース、オブジェクト指向のプログラミング開発に対応しています。

Ruby on Rails 4

Ruby on Rails4はRubyによって書かれたオープンソースのウェブフレームワークです。 Ruby on Railsは「設定より規約」の原則に従っており、効率的に作業を行うために再開発を行う必要をなくしてくれます。

HTML

HTMLとは、ウェブ上の文書を記述・作成するためのマークアップ言語のことです。文章の中に記述することで、文書の論理構造などを設定することができます。ハイパーリンクを設定できるハイパーテキストであり、画像・リスト・表などのデータファイルをリンクする情報に結びつけて情報を整理します。現在あるネットワーク上のほとんどのウェブページはHTMLで作成されています。

0グッド

1クリップ

投稿2019/10/09 05:13

編集2019/10/09 07:53

私は、今ユーザーがサインアップ後に承認メールが送られるようにしたいと考えています。しかし、ターミナルでは動いているのですが、実際にメールが送られていない状態にあります。もしわかる方がいらしたら、教えて頂きたいです。

参考にしたサイト:https://github.com/plataformatec/devise/wiki/How-To:-Require-admin-to-activate-account-before-sign_in

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>

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

ベストアンサー

「ターミナルで動いているが、送信されない」というのがよくわかりませんが、

to: '<#{@guider.email}>',

to: "<#{@guider.email}>",

とすればいいのではないでしょうか。

投稿2019/10/09 07:02

編集2019/10/09 07:23
退会済みユーザー

退会済みユーザー

総合スコア0

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

avicii

2019/10/09 14:10

動きました。ありがとうございます。
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.50%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問