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

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

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

SendGridは、米SendGrid社のクラウド型メール配信サービス。アカウントを作成するだけですぐに利用することが可能です。さらに到達率向上のための送信ドメイン認証対応や、柔軟性のあるスケーラビリティなど多くの機能を有します。

Ruby

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

Ruby on Rails

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

Q&A

1回答

690閲覧

Sendgridにメールが送れない

nana777

総合スコア16

SendGrid

SendGridは、米SendGrid社のクラウド型メール配信サービス。アカウントを作成するだけですぐに利用することが可能です。さらに到達率向上のための送信ドメイン認証対応や、柔軟性のあるスケーラビリティなど多くの機能を有します。

Ruby

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

Ruby on Rails

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

0グッド

1クリップ

投稿2019/09/17 03:12

現在、Railsチュートリアルにて学習中の者です。
Sign in の時に、Sendgridにメールを送って認証したら、log inできるという機能を作っているのですが、Send gridの方にメールが届かないので、メール送信の処理に問題がないか試してみました。→ > heroku run rails console
すると、エラーが出ました。

Running rails console on ⬢ peaceful-ravine-95504... up, run.8934 (Free) Traceback (most recent call last): 49: from /app/bin/rails:9:in `<main>' 48: from /app/bin/rails:9:in `require' 47: from /app/vendor/bundle/ruby/2.5.0/gems/railties-5.1.6/lib/rails/commands.rb:16:in `<top (required)>' 46: from /app/vendor/bundle/ruby/2.5.0/gems/railties-5.1.6/lib/rails/command.rb:44:in `invoke' 45: from /app/vendor/bundle/ruby/2.5.0/gems/railties-5.1.6/lib/rails/command/base.rb:63:in `perform' 44: from /app/vendor/bundle/ruby/2.5.0/gems/thor-0.20.3/lib/thor.rb:387:in `dispatch' 43: from /app/vendor/bundle/ruby/2.5.0/gems/thor-0.20.3/lib/thor/invocation.rb:126:in `invoke_command' 42: from /app/vendor/bundle/ruby/2.5.0/gems/thor-0.20.3/lib/thor/command.rb:27:in `run' 41: from /app/vendor/bundle/ruby/2.5.0/gems/railties-5.1.6/lib/rails/commands/console/console_command.rb:96:in `perform' 40: from /app/vendor/bundle/ruby/2.5.0/gems/railties-5.1.6/lib/rails/command/actions.rb:16:in `require_application_and_environment!' 39: from /app/vendor/bundle/ruby/2.5.0/gems/railties-5.1.6/lib/rails/application.rb:329:in `require_environment!' 38: from /app/vendor/bundle/ruby/2.5.0/gems/railties-5.1.6/lib/rails/application.rb:329:in `require' 37: from /app/config/environment.rb:5:in `<top (required)>' 36: from /app/vendor/bundle/ruby/2.5.0/gems/railties-5.1.6/lib/rails/application.rb:353:in `initialize!' 35: from /app/vendor/bundle/ruby/2.5.0/gems/railties-5.1.6/lib/rails/initializable.rb:58:in `run_initializers' 34: from /app/vendor/ruby-2.5.5/lib/ruby/2.5.0/tsort.rb:205:in `tsort_each' 33: from /app/vendor/ruby-2.5.5/lib/ruby/2.5.0/tsort.rb:226:in `tsort_each' 32: from /app/vendor/ruby-2.5.5/lib/ruby/2.5.0/tsort.rb:347:in `each_strongly_connected_component' 31: from /app/vendor/ruby-2.5.5/lib/ruby/2.5.0/tsort.rb:347:in `call' 30: from /app/vendor/ruby-2.5.5/lib/ruby/2.5.0/tsort.rb:347:in `each' 29: from /app/vendor/ruby-2.5.5/lib/ruby/2.5.0/tsort.rb:349:in `block in each_strongly_connected_component' 28: from /app/vendor/ruby-2.5.5/lib/ruby/2.5.0/tsort.rb:431:in `each_strongly_connected_component_from' 27: from /app/vendor/ruby-2.5.5/lib/ruby/2.5.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component' 26: from /app/vendor/ruby-2.5.5/lib/ruby/2.5.0/tsort.rb:228:in `block in tsort_each' 25: from /app/vendor/bundle/ruby/2.5.0/gems/railties-5.1.6/lib/rails/initializable.rb:59:in `block in run_initializers' 24: from /app/vendor/bundle/ruby/2.5.0/gems/railties-5.1.6/lib/rails/initializable.rb:30:in `run' 23: from /app/vendor/bundle/ruby/2.5.0/gems/railties-5.1.6/lib/rails/initializable.rb:30:in `instance_exec' 22: from /app/vendor/bundle/ruby/2.5.0/gems/railties-5.1.6/lib/rails/application/finisher.rb:67:in `block in <module:Finisher>' 21: from /app/vendor/bundle/ruby/2.5.0/gems/railties-5.1.6/lib/rails/application/finisher.rb:67:in `each' 20: from /app/vendor/bundle/ruby/2.5.0/gems/railties-5.1.6/lib/rails/engine.rb:354:in `eager_load!' 19: from /app/vendor/bundle/ruby/2.5.0/gems/railties-5.1.6/lib/rails/engine.rb:473:in `eager_load!' 18: from /app/vendor/bundle/ruby/2.5.0/gems/railties-5.1.6/lib/rails/engine.rb:473:in `each' 17: from /app/vendor/bundle/ruby/2.5.0/gems/railties-5.1.6/lib/rails/engine.rb:475:in `block in eager_load!' 16: from /app/vendor/bundle/ruby/2.5.0/gems/railties-5.1.6/lib/rails/engine.rb:475:in `each' 15: from /app/vendor/bundle/ruby/2.5.0/gems/railties-5.1.6/lib/rails/engine.rb:476:in `block (2 levels) in eager_load!' 14: from /app/vendor/bundle/ruby/2.5.0/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:251:in `require_dependency' 13: from /app/vendor/bundle/ruby/2.5.0/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:335:in `depend_on' 12: from /app/vendor/bundle/ruby/2.5.0/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:357:in `require_or_load' 11: from /app/vendor/bundle/ruby/2.5.0/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:36:in `load_interlock' 10: from /app/vendor/bundle/ruby/2.5.0/gems/activesupport-5.1.6/lib/active_support/dependencies/interlock.rb:11:in `loading' 9: from /app/vendor/bundle/ruby/2.5.0/gems/activesupport-5.1.6/lib/active_support/concurrency/share_lock.rb:149:in `exclusive' 8: from /app/vendor/bundle/ruby/2.5.0/gems/activesupport-5.1.6/lib/active_support/dependencies/interlock.rb:12:in `block in loading' 7: from /app/vendor/bundle/ruby/2.5.0/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:36:in `block in load_interlock' 6: from /app/vendor/bundle/ruby/2.5.0/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:379:in `block in require_or_load' 5: from /app/vendor/bundle/ruby/2.5.0/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:292:in `require' 4: from /app/vendor/bundle/ruby/2.5.0/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:258:in `load_dependency' 3: from /app/vendor/bundle/ruby/2.5.0/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:292:in `block in require' 2: from /app/vendor/bundle/ruby/2.5.0/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:292:in `require' 1: from /app/app/controllers/sessions_controller.rb:1:in `<top (required)>' /app/app/controllers/sessions_controller.rb:7:in `<class:SessionsController>': undefined method ` ' for SessionsController:Class (NoMethodError)

session_controllerを確認しても、
エラーらしいエラーはありませんでした。

class SessionsController < ApplicationController # GET /login def new #@session = Session.new end # POST /login def create user = User.find_by(email: params[:session][:email]) if user && user.authenticate(params[:session][:password]) if user.activated? # Success log_in user params[:session][:remember_me] == '1' ? remember(user) : forget(user) redirect_back_or user else message = "Account not activated. " message += "Check your email for the activation link." flash[:warning] = message redirect_to root_url end else # Failure flash.now[:danger] = 'Invalid email/password combination' render 'new' end end # DELETE /logout def destroy log_out if logged_in? redirect_to root_url end end

問題があるのは他の部分でしょうか。

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

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

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

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

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

guest

回答1

0

全角の空白が入っています。

投稿2019/09/17 13:31

winterboum

総合スコア23329

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

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

nana777

2019/09/17 14:32

ご回答ありがとうございます。 色々全角の余白がないかいじってみたのですが、 発見することができませんでした。 具体的にどこか教えていただけると嬉しいです。
winterboum

2019/09/17 21:18

あれ、読み違えたかな、 /app/app/controllers/sessions_controller.rb:7:in `<class:SessionsController>': undefined method ` ' for SessionsController:Class (NoMethodError) とありましたので、コピペされたソースでは良くわからなかったのですが、 sessions_controller.rb:7 7行目に undefined method ` ' これ全角の空白 があると言ってるので どこかに隠れているかな、と読んだのですが 7行目ってどこになりますか? end と # POST /login の間?
nana777

2019/09/18 03:46

そうです。 行間を系sたりもしましたが、上手くいきませんでした。 heroku run rails consoleをするといつもこのような流れになります。 ec2-user:~/environment/insta_app (chang-sending-email-function) $ heroku run rails console bash: heroku: command not found ec2-user:~/environment/insta_app (chang-sending-email-function) $ source <(curl -sL https://cdn.learnenough.com/heroku_install) % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 27.5M 100 27.5M 0 0 21.1M 0 0:00:01 0:00:01 --:--:-- 21.1M mv: cannot move ‘heroku’ to ‘/usr/local/heroku’: Directory not empty ec2-user:~/environment/insta_app (chang-sending-email-function) $ heroku -v heroku/7.29.0 linux-x64 node-v11.14.0 ec2-user:~/environment/insta_app (chang-sending-email-function) $ これが原因でしょうか。
winterboum

2019/09/18 03:56

herokuは使っていないのでheroku固有のことはわかりません が ec2-user:~ の .bashrc なり .bash_profile なりに heroku利用に必要な環境設定を行うようにしておくのが良いですね。heroku利用の手引に有るのでは? で それが原因である可能性は低いと感じます。 全角空白が無いことを確認した後も、同じ場所で同じエラーですか?
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだベストアンサーが選ばれていません

会員登録して回答してみよう

アカウントをお持ちの方は

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

ただいまの回答率
85.48%

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

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

質問する

関連した質問