首页 > 解决方案 > 如果您是应用程序所有者,请查看日志以获取更多信息。错误 500

问题描述

我在 Rails 中创建了一个带有 SignUp 表单的页面,它在本地运行良好,一切都很好,所以我在 Heroku 中部署了该项目,其中 statics_page 工作得很好,但是这个表单不起作用并且给我抛出了错误:

我们很抱歉,但有些不对劲。

如果您是应用程序所有者,请查看日志以获取更多信息。

所以我查看了日志,一切正常,直到出现红色:

2020-01-26T02:13:09.077537+00:00 heroku[路由器]: at=info method=GET path="/signup" host=safe-shelf-03588.herokuapp.com request_id=a96a3ba1-41ed-4963-8f6a -5cd3676954ff fwd="181.115.249.233" dyno=web.1 连接=0ms 服务=5ms 状态=500 字节=1891 协议=https

我查看了论坛,最合乎逻辑的原因是查看路线,但错误 500 是一个非常常见的问题代码,出于不同的原因,我没有运气......

这是我的 routes.rb 文件:

Rails.application.routes.draw do
  get 'users/new'
  root 'static_pages#home'
  get  '/help',    to: 'static_pages#help'
  get  '/about',   to: 'static_pages#about'
  get  '/contact', to: 'static_pages#contact'
  get  '/signup',  to: 'users#new'
  resources :users
end

这是我的database.yml:

default: &default
  adapter: postgresql
  pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
  timeout: 5000

development:
  <<: *default
  database: 'my_app_development'

test:
  <<: *default
  database: 'my_app_test'

production:
  <<: *default
  database: sample_app_production
  username: sample_app
  password: <%= ENV['SAMPLE_APP_DATABASE_PASSWORD'] %>

我的档案:

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

和我的 puma.rb 文件以防万一:

workers Integer(ENV['WEB_CONCURRENCY'] || 2)
threads_count = Integer(ENV['RAILS_MAX_THREADS'] || 5)
threads threads_count, threads_count

preload_app!

rackup      DefaultRackup
port        ENV['PORT']     || 3000
environment ENV['RACK_ENV'] || 'development'

on_worker_boot do
  # Worker specific setup for Rails 4.1+
  # See: https://devcenter.heroku.com/articles/
  # deploying-rails-applications-with-the-puma-web-server#on-worker-boot
  ActiveRecord::Base.establish_connection
end

标签: ruby-on-railsheroku

解决方案


解决方案是使用以下命令在 Heroku 中重新安装或安装 Postgree DB:

heroku 插件:创建 heroku-postgresql:hobby-dev

制作一个 Rake db:migrate 就是这样


推荐阅读