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

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

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

HerokuはHeroku社が開発と運営を行っているPaaSの名称です。RubyやNode.js、Python、そしてJVMベース(Java、Scala、Clojureなど)の複数のプログラミング言語をサポートしている。

Ruby on Rails

Ruby on Railsは、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

Q&A

解決済

1回答

317閲覧

railsチュートリアル sample app の認証メールがHeroku上で送信できない。

takuo5

総合スコア48

Heroku

HerokuはHeroku社が開発と運営を行っているPaaSの名称です。RubyやNode.js、Python、そしてJVMベース(Java、Scala、Clojureなど)の複数のプログラミング言語をサポートしている。

Ruby on Rails

Ruby on Railsは、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

0グッド

1クリップ

投稿2019/11/20 12:53

編集2019/11/21 00:16

前提・実現したいこと

railsチュートリアルの11章(認証メール送信機能の実装)リンク内容の最後にherokuへデプロイし、本番環境でsign upして認証メールを送信しようと試みましたが下記エラーメッセージが出て失敗しました。
イメージ説明
開発環境では全てのテストは通っており、設定もチュートリアルどおりに出来ているはずなのですが、どこに問題があるのか見当がつきません。
どのように解決すればよいでしょうか。

 development.rb

Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. # In the development environment your application's code is reloaded on # every request. This slows down response time but is perfect for development # since you don't have to restart the web server when you make code changes. config.cache_classes = false # Do not eager load code on boot. config.eager_load = false # Show full error reports. config.consider_all_requests_local = true # Enable/disable caching. By default caching is disabled. if Rails.root.join('tmp/caching-dev.txt').exist? config.action_controller.perform_caching = true config.cache_store = :memory_store config.public_file_server.headers = { 'Cache-Control' => "public, max-age=#{2.days.seconds.to_i}" } else config.action_controller.perform_caching = false config.cache_store = :null_store end # Don't care if the mailer can't send. config.action_mailer.raise_delivery_errors = true config.action_mailer.delivery_method = :test host = 'https://evening-ridge-47211.herokuapp.com/' # ここをコピペすると失敗します。自分の環境に合わせてください。 config.action_mailer.default_url_options = { host: host } ActionMailer::Base.smtp_settings = { :address => 'smtp.sendgrid.net', :port => '587', :authentication => :plain, :user_name => ENV['SENDGRID_USERNAME'], :password => ENV['SENDGRID_PASSWORD'], :domain => 'heroku.com', :enable_starttls_auto => true } config.action_mailer.perform_caching = false # Print deprecation notices to the Rails logger. config.active_support.deprecation = :log # Raise an error on page load if there are pending migrations. config.active_record.migration_error = :page_load # Debug mode disables concatenation and preprocessing of assets. # This option may cause significant delays in view rendering with a large # number of complex assets. config.assets.debug = true # Suppress logger output for asset requests. config.assets.quiet = true # Raises error for missing translations # config.action_view.raise_on_missing_translations = true # Use an evented file watcher to asynchronously detect changes in source code, # routes, locales, etc. This feature depends on the listen gem. config.file_watcher = ActiveSupport::EventedFileUpdateChecker end

 Heroku logs

2019-11-20T12:20:08.744164+00:00 app[web.1]: I, [2019-11-20T12:20:08.744091 #4] INFO -- : [f52d78bb-0df1-44a6-b935-ea15e8c0c161] Completed 500 Internal Server Error in 194ms (ActiveRecord: 12.6ms) 2019-11-20T12:20:08.745390+00:00 app[web.1]: F, [2019-11-20T12:20:08.745314 #4] FATAL -- : [f52d78bb-0df1-44a6-b935-ea15e8c0c161] 2019-11-20T12:20:08.745542+00:00 app[web.1]: F, [2019-11-20T12:20:08.745460 #4] FATAL -- : [f52d78bb-0df1-44a6-b935-ea15e8c0c161] ActionView::Template::Error (Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true):

試したこと

herokuのデータベースをリセットし、サイド作成し直して見ましたが結果は同じでした。

補足情報(FW/ツールのバージョンなど)

AWS Cloud9
Heroku

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

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

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

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

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

CHERRY

2019/11/20 23:34

heroku logs 等でエラーが表示されていたりしないでしょうか?
takuo5

2019/11/21 00:20

heroku logsで調べてみると、templateエラーが出ているのですが、これがメール送信を失敗させている原因でしょうか。 hostのURLは'https://evening-ridge-47211.herokuapp.com'とheroku上でのアプリケーションのURLに設定しておりますがこれが間違っているのでしょうか?
guest

回答1

0

自己解決

development.rbではなく、production.rbのほうでhostのURL設定をすることで解決できました。

投稿2019/11/22 05:40

takuo5

総合スコア48

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

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

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

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

ただいまの回答率
85.50%

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

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

質問する

関連した質問