1

我按照 Heroku 官方指南将 rails 项目推送到herokuapplication.rb文件没问题,我以正确的方式添加了pggem database.yml。当我推到heroku时,我得到:

-----> Preparing app for Rails asset pipeline
Detected manifest.yml, assuming assets were compiled locally

但是当我通过打开heroku时heroku open出现错误。我放了heroku日志并得到了这个。

Started GET "/" for 93.45.227.255 at 2012-10-11 13:28:04 +0000
2012-10-11T13:28:04+00:00 app[web.1]: Processing by ProductsController#index as HTML
2012-10-11T13:28:04+00:00 app[web.1]: :             SELECT a.attname, format_type(a.atttypid, a.atttypmod), d.adsrc, a.attnotnull
2012-10-11T13:28:04+00:00 app[web.1]: ActiveRecord::StatementInvalid (PG::Error: ERROR:  relation "products" does not exist
2012-10-11T13:28:04+00:00 app[web.1]: LINE 4:              WHERE a.attrelid = '"products"'::regclass
2012-10-11T13:28:04+00:00 heroku[router]: GET gift4.herokuapp.com/ dyno=web.1 queue=0 wait=0ms service=203ms status=500 bytes=643
2012-10-11T13:28:04+00:00 app[web.1]: ):
2012-10-11T13:28:04+00:00 app[web.1]:                 ON a.attrelid = d.adrelid AND a.attnum = d.adnum
2012-10-11T13:28:04+00:00 app[web.1]: 
2012-10-11T13:28:04+00:00 app[web.1]: 
2012-10-11T13:28:04+00:00 app[web.1]:                                         ^
2012-10-11T13:28:04+00:00 app[web.1]: 
2012-10-11T13:28:04+00:00 app[web.1]: Completed 500 Internal Server Error in 72ms
2012-10-11T13:28:04+00:00 app[web.1]:               FROM pg_attribute a LEFT JOIN pg_attrdef d
2012-10-11T13:28:04+00:00 app[web.1]:              WHERE a.attrelid = '"products"'::regclass
2012-10-11T13:28:04+00:00 app[web.1]:                AND a.attnum > 0 AND NOT a.attisdropped
2012-10-11T13:28:04+00:00 app[web.1]:              ORDER BY a.attnum
2012-10-11T13:28:04+00:00 app[web.1]:   app/controllers/products_controller.rb:5:in `index'
2012-10-11T13:28:04+00:00 heroku[router]: GET gift4.herokuapp.com/favicon.ico d

所以我尝试了

heroku run rake db:reset

得到这个

Heroku client internal error.
!    Search for help at: https://help.heroku.com
!    Or report a bug at: https://github.com/heroku/heroku/issues/new

    Error:       Operation timed out - connect(2) (Errno::ETIMEDOUT)
    Backtrace:   /Users/francescochecco/.rvm/gems/ruby-1.9.3-p194/gems/heroku-2.32.6/lib/heroku/client/rendezvous.rb:39:in `initialize'
                 /Users/francescochecco/.rvm/gems/ruby-1.9.3-p194/gems/heroku-2.32.6/lib/heroku/client/rendezvous.rb:39:in `open'
                 /Users/francescochecco/.rvm/gems/ruby-1.9.3-p194/gems/heroku-2.32.6/lib/heroku/client/rendezvous.rb:39:in `block in start'
                 /Users/francescochecco/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/timeout.rb:68:in `timeout'
                 /Users/francescochecco/.rvm/gems/ruby-1.9.3-p194/gems/heroku-2.32.6/lib/heroku/client/rendezvous.rb:31:in `start'
                 /Users/francescochecco/.rvm/gems/ruby-1.9.3-p194/gems/heroku-2.32.6/lib/heroku/command/run.rb:125:in `rendezvous_session'
                 /Users/francescochecco/.rvm/gems/ruby-1.9.3-p194/gems/heroku-2.32.6/lib/heroku/command/run.rb:112:in `run_attached'
                 /Users/francescochecco/.rvm/gems/ruby-1.9.3-p194/gems/heroku-2.32.6/lib/heroku/command/run.rb:21:in `index'
                 /Users/francescochecco/.rvm/gems/ruby-1.9.3-p194/gems/heroku-2.32.6/lib/heroku/command.rb:206:in `run'
                 /Users/francescochecco/.rvm/gems/ruby-1.9.3-p194/gems/heroku-2.32.6/lib/heroku/cli.rb:28:in `start'
                 /Users/francescochecco/.rvm/gems/ruby-1.9.3-p194/gems/heroku-2.32.6/bin/heroku:16:in `<top (required)>'
                 /Users/francescochecco/.rvm/gems/ruby-1.9.3-p194/bin/heroku:19:in `load'
                 /Users/francescochecco/.rvm/gems/ruby-1.9.3-p194/bin/heroku:19:in `<main>'
                 /Users/francescochecco/.rvm/gems/ruby-1.9.3-p194/bin/ruby_noexec_wrapper:14:in `eval'
                 /Users/francescochecco/.rvm/gems/ruby-1.9.3-p194/bin/ruby_noexec_wrapper:14:in `<main>'

    Command:     heroku run rake db:reset
    Version:     heroku-gem/2.32.6 (x86_64-darwin11.3.0) ruby/1.9.3 autoupdate

我什么都试过了。任何人都可以帮忙吗?

4

3 回答 3

2

你迁移数据库了吗?这个错误:

(PG::Error: ERROR:  relation "products" does not exist

...通常表明您缺少一张桌子。在这种情况下,您的products表可能不存在。

我同意db:reset应该为你加载你的模式,所以理论上应该可以解决上述问题。但是,超时很奇怪,而且可能是暂时的。

尝试再次推送您的应用程序,然后在您的命令行上尝试:

heroku run rake db:reset

...或者

heroku run rake db:migrate

...让我知道会发生什么。

另外,您的应用程序试图使用什么数据库(我猜是 Postgres)?productionheroku 通常会忽略您的部分database.yml,因为它们会注入自己的production数据库部分。

于 2012-10-11T13:56:58.540 回答
0

推送之前是否在本地编译过?如果是这样,则生成了 manifest.yml,并且可能导致 heroku 方面的错误。已经很长时间了,但我曾经在本地预编译(不知道为什么)并且我遇到了这样的错误......我想。不要在本地预编译。如果您曾经在本地预编译过,请进入您的公共目录并删除生成的资产文件夹。然后推送到heroku,看看它是否可以远程编译并解决你的问题。

于 2012-10-13T17:54:59.870 回答
0

你应该重置 heroku 数据库

$ heroku pg:reset SHARED_DATABASE --confirm myapp

然后做$ heroku restart

看看是否有帮助

然后尝试迁移

于 2012-10-11T15:33:41.587 回答