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

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

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

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

Ruby on Rails

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

Q&A

0回答

618閲覧

開発環境では動作するが本番環境で「We're sorry, but something went wrong.」のエラーが表示される

a-sk8

a-sk8

総合スコア5

Heroku

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

Ruby on Rails

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

0グッド

0クリップ

投稿2020/05/16 05:48

前提・実現したいこと

現在、レイルズチュートリアルで演習を行っています。 

開発環境はクラウド9です。

第7章の最後のherokuへのデプロイがうまくいかないので質問させていただきました。

実際にherokuへデプロイすると最初のsample_appのホーム画面やユーザー登録画面などは問題なく表示されるのですが、実際にユーザー登録をしてCreate my accoountボタンを押すと画像のような画面が出てしまいエラーとなります。
イメージ説明

開発環境などでは問題なくユーザー登録ができデータベースなどにも保存されているのでlコードには問題がないように思うのですが、、、どこがおかしいのか分からなくなってしまったのでご教授お願いします

該当のソースコード

↓users_controller.rb

class UsersController < ApplicationController def show @user = User.find_by(params[:id]) end def new @user = User.new end def create @user = User.new(user_params) if @user.save flash[:success] = "Welcome to the Sample App!" redirect_to @user else render 'new' end end private def user_params params.require(:user).permit(:name, :email, :password, :password_confirmation) end end

↓production.rbのコードです

production.rb

1Rails.application.configure do 2 # Settings specified here will take precedence over those in config/application.rb. 3 config.force_ssl = true 4 # Code is not reloaded between requests. 5 config.cache_classes = true 6 7 # Eager load code on boot. This eager loads most of Rails and 8 # your application in memory, allowing both threaded web servers 9 # and those relying on copy on write to perform better. 10 # Rake tasks automatically ignore this option for performance. 11 config.eager_load = true 12 13 # Full error reports are disabled and caching is turned on. 14 config.consider_all_requests_local = false 15 config.action_controller.perform_caching = true 16 17 # Disable serving static files from the `/public` folder by default since 18 # Apache or NGINX already handles this. 19 config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present? 20 21 # Compress JavaScripts and CSS. 22 config.assets.js_compressor = :uglifier 23 # config.assets.css_compressor = :sass 24 25 # Do not fallback to assets pipeline if a precompiled asset is missed. 26 config.assets.compile = false 27 28 # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb 29 30 # Enable serving of images, stylesheets, and JavaScripts from an asset server. 31 # config.action_controller.asset_host = 'http://assets.example.com' 32 33 # Specifies the header that your server uses for sending files. 34 # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache 35 # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX 36 37 # Mount Action Cable outside main process or domain 38 # config.action_cable.mount_path = nil 39 # config.action_cable.url = 'wss://example.com/cable' 40 # config.action_cable.allowed_request_origins = [ 'http://example.com', /http://example.*/ ] 41 42 # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. 43 # config.force_ssl = true 44 45 # Use the lowest log level to ensure availability of diagnostic information 46 # when problems arise. 47 config.log_level = :debug 48 49 # Prepend all log lines with the following tags. 50 config.log_tags = [ :request_id ] 51 52 # Use a different cache store in production. 53 # config.cache_store = :mem_cache_store 54 55 # Use a real queuing backend for Active Job (and separate queues per environment) 56 # config.active_job.queue_adapter = :resque 57 # config.active_job.queue_name_prefix = "sample_app_#{Rails.env}" 58 config.action_mailer.perform_caching = false 59 60 # Ignore bad email addresses and do not raise email delivery errors. 61 # Set this to true and configure the email server for immediate delivery to raise delivery errors. 62 # config.action_mailer.raise_delivery_errors = false 63 64 # Enable locale fallbacks for I18n (makes lookups for any locale fall back to 65 # the I18n.default_locale when a translation cannot be found). 66 config.i18n.fallbacks = true 67 68 # Send deprecation notices to registered listeners. 69 config.active_support.deprecation = :notify 70 71 # Use default logging formatter so that PID and timestamp are not suppressed. 72 config.log_formatter = ::Logger::Formatter.new 73 74 # Use a different logger for distributed setups. 75 # require 'syslog/logger' 76 # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name') 77 78 if ENV["RAILS_LOG_TO_STDOUT"].present? 79 logger = ActiveSupport::Logger.new(STDOUT) 80 logger.formatter = config.log_formatter 81 config.logger = ActiveSupport::TaggedLogging.new(logger) 82 end 83 84 # Do not dump schema after migrations. 85 config.active_record.dump_schema_after_migration = false 86end

↓puma.rbのコードです

puma.rb

1 2workers Integer(ENV['WEB_CONCURRENCY'] || 2) 3threads_count = Integer(ENV['RAILS_MAX_THREADS'] || 5) 4threads threads_count, threads_count 5 6preload_app! 7 8rackup DefaultRackup 9port ENV['PORT'] || 3000 10environment ENV['RACK_ENV'] || 'development' 11 12on_worker_boot do 13 # Worker specific setup for Rails 4.1+ 14 # See: https://devcenter.heroku.com/articles/ 15 # deploying-rails-applications-with-the-puma-web-server#on-worker-boot 16 ActiveRecord::Base.establish_connection 17end

Profile

1web: bundle exec puma -C config/puma.rb

調べるとheroku logs -tでエラーを探せると聞いたので実際に実行したのが以下の結果です。

Terminal

12020-05-16T04:36:32.925277+00:00 app[web.1]: I, [2020-05-16T04:36:32.925171 #10] INFO -- : [843694cf-9b93-4514-b086-450f9495dcd0] Started GET "/users/10" for 92.202.191.69 at 2020-05-16 04:36:32 +0000 22020-05-16T04:36:32.926252+00:00 app[web.1]: I, [2020-05-16T04:36:32.926181 #10] INFO -- : [843694cf-9b93-4514-b086-450f9495dcd0] Processing by UsersController#show as HTML 32020-05-16T04:36:32.926316+00:00 app[web.1]: I, [2020-05-16T04:36:32.926264 #10] INFO -- : [843694cf-9b93-4514-b086-450f9495dcd0] Parameters: {"id"=>"10"} 42020-05-16T04:36:32.932045+00:00 app[web.1]: D, [2020-05-16T04:36:32.931946 #10] DEBUG -- : [843694cf-9b93-4514-b086-450f9495dcd0] User Load (1.6ms) SELECT "users".* FROM "users" WHERE (10) LIMIT $1 [["LIMIT", 1]] 52020-05-16T04:36:32.932426+00:00 app[web.1]: I, [2020-05-16T04:36:32.932335 #10] INFO -- : [843694cf-9b93-4514-b086-450f9495dcd0] Completed 500 Internal Server Error in 6ms (ActiveRecord: 1.6ms) 62020-05-16T04:36:32.933119+00:00 app[web.1]: F, [2020-05-16T04:36:32.933052 #10] FATAL -- : [843694cf-9b93-4514-b086-450f9495dcd0] 72020-05-16T04:36:32.933172+00:00 app[web.1]: F, [2020-05-16T04:36:32.933113 #10] FATAL -- : [843694cf-9b93-4514-b086-450f9495dcd0] ActiveRecord::StatementInvalid (PG::DatatypeMismatch: ERROR: argument of WHERE must be type boolean, not type integer 82020-05-16T04:36:32.933173+00:00 app[web.1]: LINE 1: SELECT "users".* FROM "users" WHERE (10) LIMIT $1 92020-05-16T04:36:32.933173+00:00 app[web.1]: ^ 102020-05-16T04:36:32.933174+00:00 app[web.1]: : SELECT "users".* FROM "users" WHERE (10) LIMIT $1): 112020-05-16T04:36:32.933217+00:00 app[web.1]: F, [2020-05-16T04:36:32.933173 #10] FATAL -- : [843694cf-9b93-4514-b086-450f9495dcd0] 122020-05-16T04:36:32.933281+00:00 app[web.1]: F, [2020-05-16T04:36:32.933233 #10] FATAL -- : [843694cf-9b93-4514-b086-450f9495dcd0] app/controllers/users_controller.rb:4:in `show' 132020-05-16T04:56:58.096310+00:00 heroku[router]: at=info method=GET path="/signup" host=sleepy-island-12924.herokuapp.com request_id=2f8f5132-f0f1-4535-88b1-c623672ff4ef fwd="92.202.191.69" dyno=web.1 connect=1ms service=45ms status=200 bytes=3458 protocol=https 142020-05-16T04:56:58.050169+00:00 app[web.1]: I, [2020-05-16T04:56:58.050054 #8] INFO -- : [2f8f5132-f0f1-4535-88b1-c623672ff4ef] Started GET "/signup" for 92.202.191.69 at 2020-05-16 04:56:58 +0000 152020-05-16T04:56:58.051215+00:00 app[web.1]: I, [2020-05-16T04:56:58.051140 #8] INFO -- : [2f8f5132-f0f1-4535-88b1-c623672ff4ef] Processing by UsersController#new as HTML 162020-05-16T04:56:58.054679+00:00 app[web.1]: I, [2020-05-16T04:56:58.054605 #8] INFO -- : [2f8f5132-f0f1-4535-88b1-c623672ff4ef] Rendering users/new.html.erb within layouts/application 172020-05-16T04:56:58.057327+00:00 app[web.1]: I, [2020-05-16T04:56:58.057268 #8] INFO -- : [2f8f5132-f0f1-4535-88b1-c623672ff4ef] Rendered shared/_error_messages.html.erb (0.5ms) 182020-05-16T04:56:58.086894+00:00 app[web.1]: I, [2020-05-16T04:56:58.086778 #8] INFO -- : [2f8f5132-f0f1-4535-88b1-c623672ff4ef] Rendered users/new.html.erb within layouts/application (32.1ms) 192020-05-16T04:56:58.088979+00:00 app[web.1]: I, [2020-05-16T04:56:58.088908 #8] INFO -- : [2f8f5132-f0f1-4535-88b1-c623672ff4ef] Rendered layouts/_rails_default.html.erb (0.8ms) 202020-05-16T04:56:58.089661+00:00 app[web.1]: I, [2020-05-16T04:56:58.089589 #8] INFO -- : [2f8f5132-f0f1-4535-88b1-c623672ff4ef] Rendered layouts/_shim.html.erb (0.2ms) 212020-05-16T04:56:58.090589+00:00 app[web.1]: I, [2020-05-16T04:56:58.090521 #8] INFO -- : [2f8f5132-f0f1-4535-88b1-c623672ff4ef] Rendered layouts/_header.html.erb (0.5ms) 222020-05-16T04:56:58.091469+00:00 app[web.1]: I, [2020-05-16T04:56:58.091394 #8] INFO -- : [2f8f5132-f0f1-4535-88b1-c623672ff4ef] Rendered layouts/_footer.html.erb (0.4ms) 232020-05-16T04:56:58.091721+00:00 app[web.1]: I, [2020-05-16T04:56:58.091658 #8] INFO -- : [2f8f5132-f0f1-4535-88b1-c623672ff4ef] Completed 200 OK in 40ms (Views: 38.8ms | ActiveRecord: 0.0ms)

コードが長いので怪しい部分をのせました。自分的にはCompleted 500 Internal Server Error in 6ms (ActiveRecord: 1.6ms)の部分とActiveRecord::StatementInvalid (PG::DatatypeMismatch: ERROR: argument of WHERE must be type boolean, not type integer
の部分が怪しいのではと考えています。

WHEREをintegerではなくbooleanにしろ的なことが書いてあるような気がしますがいまいちどこのことを言っているのか分かりません。

それとも他にも問題があるのでしょうか?

試したこと

$ git add -A
$ git commit -m "Finish user signup"
$ git checkout master
$ git merge sign-up
$ git push
$ git push heroku
$ heroku run rails db:migrate

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

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

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

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

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

guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだ回答がついていません

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

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

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

ただいまの回答率
85.46%

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

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

質問する

関連した質問