15

Pretty new to rails/heroku. I created a clean project to help figure out what in the world is happening with heroku. Then I add to it with a:

rails generate controller Pages home contact

http://localhost:3000/pages/home shows exactly what we expect. Commit, push to git, push to heroku. Open the page on heroku and it returns the error page: "We're sorry, but something went wrong."

heroku logs don't seem to have anything interesting, and exceptional isn't registering that anything bad is happenin at all.

UPDATE: I've reduced the logs to an example of the offending bits.

2011-10-06T01:06:05+00:00 app[web.1]: Started GET "/pages/home" for 97.87.14.192 at 2011-10-05 18:06
:05 -0700
2011-10-06T01:06:05+00:00 app[web.1]:
2011-10-06T01:06:05+00:00 app[web.1]: ActiveRecord::ConnectionNotEstablished (ActiveRecord::Connecti
onNotEstablished):
2011-10-06T01:06:05+00:00 app[web.1]:
2011-10-06T01:06:05+00:00 app[web.1]:
2011-10-06T01:06:05+00:00 app[web.1]:
2011-10-06T01:06:05+00:00 app[web.1]: cache: [GET /pages/home] miss

Here's the gemfile I'm running

# gemfile
source 'http://rubygems.org'

gem 'rails', '3.1.0'

group :test do
  gem 'sqlite3-ruby', :require => 'sqlite3'
  gem 'rspec-rails', '2.6.1'
  gem 'webrat', '0.7.1'
end

group :development, do
  gem 'sqlite3-ruby', :require => 'sqlite3'
  gem 'rspec-rails', '2.6.1'
end
DavidMann10k
  • 553
  • 1
  • 4
  • 12
  • Thanks for taking a look, guys. I added the Heroku logs. If there's something there I don't know what it is. – DavidMann10k Oct 06 '11 at 01:18
  • janders is right, its probably a database.yml error thats stopping it. make sure that you have the right gems in your gemfile and do a bundle just in case. p.s. you might want to take your email out of those logs just in case. :) – cbron Oct 06 '11 at 01:45
  • Ok, my gemfile seems most suspect because that is literally all I've changed before the `generate controller`. I'm putting up a copy of that for examination. – DavidMann10k Oct 06 '11 at 01:57
  • Did you do a `heroku rake db:migrate` ? This might help you out: http://devcenter.heroku.com/articles/quickstart#prerequisites – cbron Oct 06 '11 at 02:16

4 Answers4

46

This is just a generic heroku error so you don't display sensitive info to end users. Just type heroku logs in rails root and you should see the latest server details including your error.

If you have to run migrations the command is:

heroku run rake db:migrate

(Thanks to lampshady)

cbron
  • 4,036
  • 3
  • 33
  • 40
  • 1
    This is the answer, sort of! I got errors when I tried to rake, and that led me to [this answer](http://stackoverflow.com/questions/3747002/heroku-rails-3-and-sqlite3) - I updated my gemfile, pushed and raked again. Bam! – DavidMann10k Oct 06 '11 at 02:35
  • Yes, and more importantly I have some resources bookmarked to prevent future me some pain. Thanks. – DavidMann10k Oct 06 '11 at 02:45
3

Migrate your database on heroku then redeploy the app and restart the heroku server. Thats all you need to do.

  heroku rake db:migrate

  git push heroku master

  heroku restart
Prabhakar
  • 6,458
  • 2
  • 40
  • 51
1

Running the logs 'heroku logs', has a key giveaway: PG::Error: ERROR: relation "<Rails Model>" does not exist. This entry states your model could not be loaded.

To provide an update to previous answers, heroku rake has been deprecated. Heroku requires:

heroku run rake db:migrate
Lampshady
  • 102
  • 4
0

From your heroku log ActiveRecord::ConnectionNotEstablished (ActiveRecord::Connecti onNotEstablished):. From the Rails API Doc, this error is raised when a connection to the database could not be established. I am guessing that your error may be in your database.yml file, most likely parameters not set for your production database.

janders223
  • 3,123
  • 2
  • 22
  • 27