framomo86
framomo86

Reputation: 1205

Can't get heroku work with rails 3.x postgresql

I followed Heroku official guides to push rails project to heroku. The application.rb file is ok, I added pg gem and database.yml in the right way. When I push to heroku I get:

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

But when I open heroku via heroku open I get an error. I put heroku logs and get this.

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

So I tried

heroku run rake db:reset

And get this

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

I tried everything. Anyone could help?

Upvotes: 1

Views: 375

Answers (3)

hellion
hellion

Reputation: 4830

Did you compile locally before you pushed? If so a manifest.yml was generated and may be causing the error on the heroku side. Its been a long time, but I used to precompile locally (not sure why) and I had errors like this...I think. Don't precompile locally. If you have ever precompiled locally go into your public directory and delete the generated assets folder. Then push to heroku and see if it compiles remotely and clears your problem.

Upvotes: 0

Nick Ginanto
Nick Ginanto

Reputation: 32130

You should reset the heroku db with

$ heroku pg:reset SHARED_DATABASE --confirm myapp

and then do $ heroku restart

see if that helps

then try to migrate

Upvotes: 0

jefflunt
jefflunt

Reputation: 33954

Did you migrate the database? This error:

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

...usually indicates that you have a table missing. In this case, your products table probably doesn't exist.

I agree that db:reset should load your schema for you, so this should resolve the above problem, theoretically. However, the timeout is weird, and maybe temporary.

Try to push your app again, then on your command line, try:

heroku run rake db:reset

...or

heroku run rake db:migrate

...and let me know what happens.

Also, what database is your app trying to use (I'm guessing Postgres)? The production section of your database.yml is typically ignored by heroku, as they inject their own production database section.

Upvotes: 2

Related Questions