【发布时间】:2020-01-26 02:36:03
【问题描述】:
我在 Rails 中创建了一个带有 SignUp 表单的页面,它在本地运行良好,一切都很好,所以我在 Heroku 中部署了该项目,其中 statics_page 可以完美运行,但是此表单无法正常工作,并且给我抛出了错误:
很抱歉,出了点问题。
如果您是应用程序所有者,请查看日志以获取更多信息。
所以我查看了日志,一切正常,直到显示为红色:
2020-01-26T02:13:09.077537+00:00 heroku[路由器]: at=info method=GET path="/signup" 主机=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'] %>
我的 Procfile:
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
【问题讨论】:
-
我认为你有重复的路线并不重要。但是当您
rake routes查看实际路径时,您会得到什么?还只是检查您没有任何尚未在 Heroku 上运行的迁移?这是我在推送 Heroku 时经常忘记的。 -
您也可以运行
heroku local,它会尝试在本地像您的生产版本一样运行,以便您对其进行测试。 -
@Beartech 我可以访问 Heroku 中的索引和静态页面,但注册链接已损坏,我还运行了命令 "heroku run rake db:migrate" 。我只是尝试运行“heroku local”,它运行良好,一切加载都没有问题
-
您是否设置了 postgres 数据库?这就是它正在寻找的东西。如果你有你需要为密码设置你的 ENV 变量,它位于 Heroku 网页的“设置”选项卡下。
-
Heroku 有一个免费的 postgres 层,限制为 10,000 行。我用它来测试。
标签: ruby-on-rails heroku