Rails Heroku应用程序错误 [英] Rails Heroku application error

查看:83
本文介绍了Rails Heroku应用程序错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试将我的rails应用程序推送到heroku,但遇到以下错误:

 应用程序错误

应用程序发生错误,您的页面无法投放。请稍后重试。

如果您是应用程序所有者,请查看您的日志以了解详细信息。

因为我使用的是sqlite3

我应该在网络搜索上进行搜索以下内容:

  heroku rake db:创建
heroku rake db:迁移

heroku rake db:抱怨创建失败


 请安装postgresql适配器:`gem install activerecord-postgresql-adapter`(pg不是捆绑包的一部分,将它添加到Gemfile中)

命令 gem install activerecord-postgresql-adapter 失败并抱怨

 错误:无法在任何存储库中找到有效的gem'activerecord-postgresql-adapter'(> = 0)
错误:可能替代品:activerecord-postgis-adapter,activerecord-jdbcpostgresql-adapter,activerecord-postgresql-cursors,activerecord-jdbcmysql-adapter,activerecord-jdbcmssql-adapter

然后我再次在网上搜索并按照 http://devcenter.heroku.com/articles/how-do-i-use -sqlite3-for-development 建议更改

  gem'sqlite3'

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

并运行

 捆绑安装 - 无需生产

但是这并没有解决问题
另一个来源说我需要这样做

  group:production do 
gem'therubyracer-heroku','0.8.1.pre3'
gempg
end

这也未能解决问题

我的系统上安装了postresql。
那么究竟是什么问题?

解决方案

这里的关键是需要 pg gem在部署到heroku时最终使用的Postgres数据库运行(http://devcenter.heroku.com/articles/database)



理想情况下,您希望在本地运行Postgres,以便从数据库的角度看,开发和生产之间没有任何区别。



如果您想坚持如何使用它们,只需添加 gempg到您的Gemfile应该可以解决这个问题。



添加完成后,运行:

  bundle install 
git add。
git commit -am在Gemfile中添加了PG
git push heroku master $ b $ heroku rake db:migrate


I try to push my rails application to heroku but encountered the following error

Application Error

An error occurred in the application and your page could not be served. Please try again in a few moments.

If you are the application owner, check your logs for details.

Because I am using sqlite3
A search on the web show I should do the following

heroku rake db:create
heroku rake db:migrate

the heroku rake db:create failed by complaining

Please install the postgresql adapter: `gem install activerecord-postgresql-adapter` (pg is not part of the bundle. Add it to Gemfile.)

The command gem install activerecord-postgresql-adapter failed and complains

ERROR:  Could not find a valid gem 'activerecord-postgresql-adapter' (>= 0) in any repository
ERROR:  Possible alternatives: activerecord-postgis-adapter, activerecord-jdbcpostgresql-adapter, activerecord-postgresql-cursors, activerecord-jdbcmysql-adapter, activerecord-jdbcmssql-adapter

Then I searched the web again and followed the http://devcenter.heroku.com/articles/how-do-i-use-sqlite3-for-development suggestion to change

gem 'sqlite3'

to

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

and run

bundle install --without production

however this did not solve the problem another source say I need to do like

group :production do
   gem 'therubyracer-heroku', '0.8.1.pre3'
   gem "pg"
end

This also failed to solve the issue

I have postresql installed on my system. So what hell is the problem?

解决方案

The key thing here is that the pg gem is required to run against the Postgres database that you end up using when you deploy to heroku (http://devcenter.heroku.com/articles/database)

Ideally, you want to be running Postgres locally so that you're not seeing any differences between development and production from a database standpoint.

If you want to stick with things how you have them simply adding gem "pg" to your Gemfile should fix this.

Once added, run:

bundle install
git add .
git commit -am "Added PG to Gemfile"
git push heroku master
heroku rake db:migrate

这篇关于Rails Heroku应用程序错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆