简体   繁体   English

Rails应用程序部署到Heroku错误

[英]Rails App Deploy to Heroku Error

I'm trying to deploy my first app from Github to Heroku. 我正在尝试将我的第一个应用程序从Github部署到Heroku。 I press “Deploy branch” and get message: 我按“部署分支”并收到消息:

“Your app was successfully deployed” “您的应用已成功部署”

But when I open the view, I see the following message instead of my app: 但是,当我打开视图时,看到的不是我的应用程序,而是以下消息:

“Application error. “应用程序错误。 An error occurred in the application and your page could not be served. 应用程序中发生错误,无法提供您的页面。 If you are the application owner, check your logs for details” 如果您是应用程序所有者,请查看日志以了解详细信息”

I've tried many things to fix it, but the result is still the same and can't find what I'm doing wrong. 我已经尝试了许多方法来修复它,但是结果仍然是一样的,并且找不到我在做什么错。 How can I fix my deploy correctly and see my app up and running on Heroku? 如何正确修复我的部署并查看我的应用程序在Heroku上运行?

Heroku build log: Heroku构建日志:

https://gist.github.com/Evanto/4ce2afa5a9e75b7154727356d77737e1 https://gist.github.com/Evanto/4ce2afa5a9e75b7154727356d77737e1

Github branch I'm trying to deploy to Heroku: 我正尝试部署到Heroku的Github分支:

https://github.com/Evanto/MovieApp/tree/heroku https://github.com/Evanto/MovieApp/tree/heroku

https://movieapps.herokuapp.com/ https://movieapps.herokuapp.com/

In your logs, it says the following: 在您的日志中,它显示以下内容:

Gem::LoadError: Specified 'postgresql' for database adapter, but the gem is not loaded. Gem :: LoadError:为数据库适配器指定了“ postgresql”,但未加载gem。 Add gem 'pg' to your Gemfile 将gem'pg gem 'pg'添加到您的Gemfile

Heroku supports only pg as the database of choice, so you need to add the following line to your Gemfile . Heroku仅支持pg作为选择的数据库,因此您需要Gemfile添加到Gemfile

gem 'pg'

Edit: 编辑:

No, you do need to need any username or password in your database.yml file for Heroku. 不,您确实需要在Database.yml文件中输入Heroku的任何用户名或密码。 Writing the following in the said file will work fine for you. 在上述文件中写入以下内容对您来说很好。

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

development:
  <<: *default
  database: project_name_development
production:
  <<: *default
  database: project_name_production
test:
  <<: *default
  database: project_name_test

Gemfile 宝石文件

gem 'pg'

config/database.yml config / database.yml

default: &default
  adapter: postgresql
  pool: 5
  timeout: 5000
  username : root
  password : root
  database: db_name

development:
  <<: *default

test:
  <<: *default

production:
  <<: *default

On terminal: 在终端上:

rake db:migrate

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM