前提・実現したいこと
Rails勉強始めたての初心者です。
http://kurome-stdio.hatenablog.com/entry/2017/09/02/214203
こちらのサイトを参考にTwitterAPIを利用してタイムラインを取得するWebアプリを作成していますが、
heroku環境にデプロイして確認すると/auth/twitterが存在しないというエラーメッセージが帰ってきます。
発生している問題・エラーメッセージ
ローカル環境でのエラー
No route matches [GET] "/auth/twitter" Rails.root: /home/ec2-user/environment/cloudder2 Application Trace | Framework Trace | Full Trace actionpack (5.2.2.1) lib/action_dispatch/middleware/debug_exceptions.rb:65:in `call' web-console (3.7.0) lib/web_console/middleware.rb:135:in `call_app' web-console (3.7.0) lib/web_console/middleware.rb:22:in `block in call' web-console (3.7.0) lib/web_console/middleware.rb:20:in `catch' web-console (3.7.0) lib/web_console/middleware.rb:20:in `call' actionpack (5.2.2.1) lib/action_dispatch/middleware/show_exceptions.rb:33:in `call' railties (5.2.2.1) lib/rails/rack/logger.rb:38:in `call_app' railties (5.2.2.1) lib/rails/rack/logger.rb:26:in `block in call' activesupport (5.2.2.1) lib/active_support/tagged_logging.rb:71:in `block in tagged' activesupport (5.2.2.1) lib/active_support/tagged_logging.rb:28:in `tagged' activesupport (5.2.2.1) lib/active_support/tagged_logging.rb:71:in `tagged' railties (5.2.2.1) lib/rails/rack/logger.rb:26:in `call' sprockets-rails (3.2.1) lib/sprockets/rails/quiet_assets.rb:13:in `call' actionpack (5.2.2.1) lib/action_dispatch/middleware/remote_ip.rb:81:in `call' actionpack (5.2.2.1) lib/action_dispatch/middleware/request_id.rb:27:in `call' rack (2.0.6) lib/rack/method_override.rb:22:in `call' rack (2.0.6) lib/rack/runtime.rb:22:in `call' activesupport (5.2.2.1) lib/active_support/cache/strategy/local_cache_middleware.rb:29:in `call' actionpack (5.2.2.1) lib/action_dispatch/middleware/executor.rb:14:in `call' actionpack (5.2.2.1) lib/action_dispatch/middleware/static.rb:127:in `call' rack (2.0.6) lib/rack/sendfile.rb:111:in `call' railties (5.2.2.1) lib/rails/engine.rb:524:in `call' puma (3.12.0) lib/puma/configuration.rb:225:in `call' puma (3.12.0) lib/puma/server.rb:658:in `handle_request' puma (3.12.0) lib/puma/server.rb:472:in `process_client' puma (3.12.0) lib/puma/server.rb:332:in `block in run' puma (3.12.0) lib/puma/thread_pool.rb:133:in `block in spawn_thread'
heroku環境でのエラー
The page you were looking for doesn't exist. You may have mistyped the address or the page may have moved. If you are the application owner check the logs for more information.
該当のソースコード
# config/settings.yml defaults: &defaults development: <<: *defaults twitter: consumer_key: <%= ENV['CONSUMER_KEY'] %> consumer_secret: <%= ENV['CONSUMER_SECRET'] %> test: <<: *defaults production: <<: *defaults
# config/initializers/0_settings.rb class Settings < Settingslogic source "#{Rails.root}/config/settings.yml" namespace Rails.env end
# .env CONSUMER_KEY = '#実際のキーを入れています。' CONSUMER_SECRET = '#実際のキーを入れています。'
# config/routes.rb Rails.application.routes.draw do root 'home#index' get 'home/index' get '/auth/:provider/callback', to: 'sessions#callback' post '/auth/:provider/callback', to: 'sessions#callback' get '/logout', to: 'sessions#destroy', as: :logout get '/home', to: 'top#timeline', as: :home post '/home/tweet', to: 'top#tweet', as: :tweet end
<!-- app/views/home/index.html.erb --> <!DOCTYPE html> <html> <head> <title>Ballooon</title> <%= csrf_meta_tags %> <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %> <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %> </head> <body> <% if current_user %> <%= current_user.name %> <%= link_to 'ログアウト', logout_path %> <% else %> <%= link_to 'ログイン', '/auth/twitter' %> <% end %> <%= yield %> </body> </html>
試したこと
.envが上手く読めずにAPIキーの認証が通らずに404エラーが返ってきているのか、またoauth系のgemの設定が上手くできていないのかと個人的には思っています。
詳しい方がおられましたら、大変お手数ですがご教授お願いします。
あなたの回答
tips
プレビュー