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

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

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

Cloud9は、クラウドからのプログラミングが可能になるWebサービス。IDEとしての機能が搭載されており、GitHubやHerokuなど他ツールとの連携も可能です。ブラウザ上で動くため、デバイスに関係なく開発環境を準備できます。

Ruby

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

IDE

IDE、統合開発環境((Integrated Development Environment)とは、テキストエディタ以上の機能を提供して、ソフトウェア開発を効率をあげるコンピュータプログラムを指す。

Ubuntu

Ubuntuは、Debian GNU/Linuxを基盤としたフリーのオペレーティングシステムです。

Ruby on Rails

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

Q&A

解決済

2回答

1327閲覧

ユーザー登録をしたい

divclass123

総合スコア35

Cloud9

Cloud9は、クラウドからのプログラミングが可能になるWebサービス。IDEとしての機能が搭載されており、GitHubやHerokuなど他ツールとの連携も可能です。ブラウザ上で動くため、デバイスに関係なく開発環境を準備できます。

Ruby

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

IDE

IDE、統合開発環境((Integrated Development Environment)とは、テキストエディタ以上の機能を提供して、ソフトウェア開発を効率をあげるコンピュータプログラムを指す。

Ubuntu

Ubuntuは、Debian GNU/Linuxを基盤としたフリーのオペレーティングシステムです。

Ruby on Rails

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

0グッド

0クリップ

投稿2020/10/21 11:59

前提・実現したいこと

Rails tutorialの11章後半のアカウントの有効化で、ユーザーがsignupしたらユーザーを登録する前にユーザーにメールを送り,ユーザーがそのリンクをクリックしたらユーザー登録できるみたいな、私たちが普段よく使うような機能を実装してるのですが、以下のようなエラーが出ました
つまりMailerを使ってる時にエラーが出ました

発生している問題・エラーメッセージ

あたらにユーザー登録したら

ruby

1Errno::ECONNREFUSED in UsersController#create 2Connection refused - connect(2) for "localhost" port 25

ruby

1 UserMailer.account_activation(@user).deliver_now 2users_contorollerのここがハイライトされてました

試したこと

エラー文で検索したところ、development.rbに関する記事が多く出てきたので
設定に問題があるのではと思い

config/development.rb

1Rails.application.configure do 2 # Settings specified here will take precedence over those in config/application.rb. 3 4 # In the development environment your application's code is reloaded on 5 # every request. This slows down response time but is perfect for development 6 # since you don't have to restart the web server when you make code changes. 7 config.cache_classes = false 8 9 # Do not eager load code on boot. 10 config.eager_load = false 11 12 # Show full error reports. 13 config.consider_all_requests_local = true 14 15 # Enable/disable caching. By default caching is disabled. 16 # Run rails dev:cache to toggle caching. 17 if Rails.root.join('tmp', 'caching-dev.txt').exist? 18 config.action_controller.perform_caching = true 19 config.action_controller.enable_fragment_cache_logging = true 20 21 config.cache_store = :memory_store 22 config.public_file_server.headers = { 23 'Cache-Control' => "public, max-age=#{2.days.to_i}" 24 } 25 else 26 config.action_controller.perform_caching = false 27 28 config.cache_store = :null_store 29 end 30 31 # Store uploaded files on the local file system (see config/storage.yml for options). 32 config.active_storage.service = :local 33 34 # Don't care if the mailer can't send. 35 36 # config.action_mailer.raise_delivery_errors = true 37 # コメントアウトすることでdelelop環境からもメールを送信する設定に 38 39 host = 'b9c7c936bba34db686385a83af09e0a0.vfs.cloud9.ap-northeast-1.amazonaws.com' # ここをコピペすると失敗します。自分の環境のホストに変えてください。 40 # クラウドIDEの場合は以下をお使いください 41 config.action_mailer.default_url_options = { host: host, protocol: 'https' } 42 # localhostで開発している場合は以下をお使いください 43 # config.action_mailer.default_url_options = { host: host, protocol: 'http' } 44 45 config.action_mailer.perform_caching = false 46 47 # Print deprecation notices to the Rails logger. 48 config.active_support.deprecation = :log 49 50 # Raise an error on page load if there are pending migrations. 51 config.active_record.migration_error = :page_load 52 53 # Highlight code that triggered database queries in logs. 54 config.active_record.verbose_query_logs = true 55 56 # Debug mode disables concatenation and preprocessing of assets. 57 # This option may cause significant delays in view rendering with a large 58 # number of complex assets. 59 config.assets.debug = true 60 61 # Suppress logger output for asset requests. 62 config.assets.quiet = true 63 64 # Raises error for missing translations. 65 # config.action_view.raise_on_missing_translations = true 66 67 # Use an evented file watcher to asynchronously detect changes in source code, 68 # routes, locales, etc. This feature depends on the listen gem. 69 config.file_watcher = ActiveSupport::EventedFileUpdateChecker 70 config.hosts.clear 71 72 73end 74

config.action_mailer.raise_delivery_errors = true
コメントアウトすることでdelelop環境からもメールを送信する設定に

の部分で、コメントアウトしたら一回うまく行ったのですがまた何故か上手くいきませんでした

またCloud9のideだと思うので、 host = 'b9c7c936bba34db686385a83af09e0a0.vfs.cloud9.ap-northeast-1.amazonaws.com'
このような記述にしたのですが、何故かlocalhostに反応してるのでますますよくわかりません。

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

自分のレベルはTechcampのカリキュラムを終えた程度で、学習歴三ヶ月の初心者です
Clound9 ubuntu
ruby 2.6.3
rails 6.0.0

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

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

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

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

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

guest

回答2

0

自己解決

ruby

1Rails.application.configure do 2 # Settings specified here will take precedence over those in config/application.rb. 3 4 # In the development environment your application's code is reloaded on 5 # every request. This slows down response time but is perfect for development 6 # since you don't have to restart the web server when you make code changes. 7 config.cache_classes = false 8 # Do not eager load code on boot. 9 config.eager_load = false 10 11 # Show full error reports. 12 config.consider_all_requests_local = true 13 14 # Enable/disable caching. By default caching is disabled. 15 # Run rails dev:cache to toggle caching. 16 if Rails.root.join('tmp', 'caching-dev.txt').exist? 17 config.action_controller.perform_caching = true 18 config.action_controller.enable_fragment_cache_logging = true 19 20 config.cache_store = :memory_store 21 config.public_file_server.headers = { 22 'Cache-Control' => "public, max-age=#{2.days.to_i}" 23 } 24 else 25 config.action_controller.perform_caching = false 26 27 config.cache_store = :null_store 28 end 29 30 # Store uploaded files on the local file system (see config/storage.yml for options). 31 config.active_storage.service = :local 32 33 # Don't care if the mailer can't send. 34 35 # config.action_mailer.raise_delivery_errors = true 36 # コメントアウトすることでdelelop環境からもメールを送信する設定に 37 38 host = 'b9c7c936bba34db686385a83af09e0a0.vfs.cloud9.ap-northeast-1.amazonaws.com' # ここをコピペすると失敗します。自分の環境のホストに変えてください。 39 # クラウドIDEの場合は以下をお使いください 40 config.action_mailer.default_url_options = { host: host, protocol: 'https' } 41 # localhostで開発している場合は以下をお使いください 42 # config.action_mailer.default_url_options = { host: host, protocol: 'http' } 43 44 config.action_mailer.perform_caching = false 45 46 # Print deprecation notices to the Rails logger. 47 config.active_support.deprecation = :log 48 49 # Raise an error on page load if there are pending migrations. 50 config.active_record.migration_error = :page_load 51 52 # Highlight code that triggered database queries in logs. 53 config.active_record.verbose_query_logs = true 54 55 # Debug mode disables concatenation and preprocessing of assets. 56 # This option may cause significant delays in view rendering with a large 57 # number of complex assets. 58 config.assets.debug = true 59 60 # Suppress logger output for asset requests. 61 config.assets.quiet = true 62 63 # Raises error for missing translations. 64 # config.action_view.raise_on_missing_translations = true 65 66 # Use an evented file watcher to asynchronously detect changes in source code, 67 # routes, locales, etc. This feature depends on the listen gem. 68 config.file_watcher = ActiveSupport::EventedFileUpdateChecker 69 config.hosts.clear 70 71 config.action_mailer.asset_host = 'b9c7c936bba34db686385a83af09e0a0.vfs.cloud9.ap-northeast-1.amazonaws.com/' 72 config.action_mailer.default_url_options = { host: 'localhost:3000' } 73 config.action_mailer.raise_delivery_errors = true 74 config.action_mailer.delivery_method = :smtp 75 config.action_mailer.smtp_settings = { 76 #enable: true, 77 address: 'smtp.gmail.com', 78 port: 587, 79 domain: 'gmail.com', 80 authentication: :login, 81 user_name: 'gmailのメアド@gmail.com', 82 password: 'アプリパスワード', 83 enable_starttls_auto: true, 84 #openssl_verify_mode: 'peer', 85 ssl: false, 86 tls: false 87 88 }

のような設定をして、

グーグルアカウントで二段階認証をオンにして、アプリパスワードを取得して、設定に記述する

投稿2020/10/28 11:36

divclass123

総合スコア35

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

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

0

「Connection refused - connect(2) for "localhost" port 25」
localhost の port 25、すなわちメールサーバーに接続できない と言ってます。 使ってるPCにメールサーバーはありますか?
無いだろうとおもいます。
gmailサーバーを使う設定をしてください。

投稿2020/10/21 23:38

winterboum

総合スコア23349

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

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

divclass123

2020/10/22 03:09

メールサーバー設定 とググったとこと、以下のような記事が出てきました https://image.raku-uru.jp/documents/mailer-setup.pdf おそらく、自分のMacでもメールのやりとりができているので、メールサーバーが機能してるとの認識でよろしいのでしょうか? 機能してるなら何故そのようなエラーが出るのでしょうか。 追加で情報をいただけたら幸いです。
divclass123

2020/10/22 04:29

gmailの設定と言うヒントをいただけて感謝しております。 おかげでそのエラーからは脱出できました。 しかし、SSL_connect returned=1 errno=0 state=error: wrong version number と言うエラーが出てしましました、、、 一旦ググって考えます。 ありがとうございました
winterboum

2020/10/22 04:34

「自分のMacでもメールのやりとりができているので、メールサーバーが機能してる」 そのメールサーバーは、Railsをdevelopmentで動かしているマシンですか?
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

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

ただいまの回答率
85.48%

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

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

質問する

関連した質問