【问题标题】:Rails app points to 500.html page when uploaded to heroku上传到 Heroku 时,Rails 应用程序指向 500.html 页面
【发布时间】:2013-03-24 05:29:40
【问题描述】:

我已经在 heroku 上创建了我的堆栈,并且所有内容都已部署,但是当我尝试通过 URL 实际访问它时,它只是默认为 500.html 错误页面。该应用程序在我的本地主机上运行良好,但我在 sqlite3 中开发了它。此后,我将 Gemfile 更改为如下所示并运行 bundle install。

#gem 'sqlite3'

gem 'thin'

group :production do
   gem 'pg'
end
group :development, :test do
   gem 'sqlite3'
end

当您访问该网址时,它应该指向我的登录页面。

这就是我的 database.yml 文件的样子...这与我的问题有什么关系吗?

development:
   adapter: sqlite3
   database: db/development.sqlite3
   pool: 5
   timeout: 5000

# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
   adapter: sqlite3
   database: db/test.sqlite3
   pool: 5
   timeout: 5000

production:
  adapter: sqlite3
  database: db/production.sqlite3
  pool: 5
  timeout: 5000

感谢您的建议

【问题讨论】:

  • 你检查你的日志了吗? heroku logs -t --app

标签: ruby-on-rails database ruby-on-rails-3 heroku


【解决方案1】:

我可以从评论中看到您正在使用 sqlite 将其用于生产 Heroku。这是不可能的,因为heroku不支持sqlite。您可以在生产环境中使用 pg 或 mysql2。您可以在这里查看解决方案:

How to configure database.yml for deployment to Heroku

完成后运行这些命令

heroku run rake db:reset
heroku run rake db:drop db:create db:seed
heroku run rake db:migrate

【讨论】:

    【解决方案2】:

    您的 database.yml 文件仍然指向 SQLite。您需要将其更改为指向 heroku 上的 PostgreSQL 数据库。

    【讨论】:

    • 这可能是一个多余的问题,但我如何将其更改为指向 PostgreSQL?我只是将“sqlite3”更改为“pg”或“postgresql”吗?我必须更改端口号吗?在 Heroku 上发布新应用时,我是新手。
    • 我不是heroku专家,所以我无法告诉你这些细节。至少,您将“sqlite3”更改为“pg”,并将数据库更改为 Postgres 数据库名称。
    【解决方案3】:

    使用heroku logs 查看显示 500 错误原因的日志文件。如果您尚未运行迁移,这可能是原因。一定要运行:

    heroku run rake db:migrate

    在您使用您的应用之前。

    【讨论】:

    • 我运行了 heroku run db:migrate 但没有检查日志。我会发布结果。
    • 糟糕,我是heroku run rake db:migrate。更新了答案。 :)
    • 我的日志很长,但这里有几行可能与我的问题有关。我能听听你的意见吗?
    • ?[36m2013-04-02T19:20:00+00:00 app[web.1]:?[0m 完成 500 次内部服务器错误或在 178 毫秒内
    • ?[36m2013-04-02T19:08:42+00:00 app[web.1]:?[0m /app/vendor/bundle/ruby/1.9.1/gem s/bundler -1.3.2/lib/bundler/rubygems_integration.rb:214:in block in replace_gem ': Please install the postgresql adapter: gem install activerecord-postgresql-a dapter`(pg 不是包的一部分。将其添加到 Gemfile。)(LoadError)
    猜你喜欢
    • 2014-10-17
    • 2021-02-26
    • 2013-08-30
    • 2013-10-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-01-01
    • 2019-10-09
    相关资源
    最近更新 更多