我用 SignUp 表单在 rails 中创建了一个页面,它在本地运行良好,一切都很好,所以我在 Heroku 中部署了该项目,statics_page在那里工作得很好,但这个表单不起作用,并且给我抛出了错误:
很抱歉,出了点问题。
如果您是应用程序所有者,请查看日志以获取更多信息。
所以我查看了日志,其中所有内容加载正常,直到出现红色:
2020-01-26T02:13:09.077537+00:00 heroku[路由器]:at=info 方法=GET 路径="/注册" 主机=安全机架 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
这是我的数据库.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
解决方案是使用以下命令在 Heroku 中重新安装或安装 Postgree DB:
heroku addons:create heroku-postgresql:hobby-dev
制作一个 Rake db:migrate 就是这样