0

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?

Neil Middleton
  • 22,105
  • 18
  • 80
  • 134
Katelynn ruan
  • 332
  • 4
  • 13

2 Answers2

1

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
Neil Middleton
  • 22,105
  • 18
  • 80
  • 134
  • I exactly followed your instruction. The webpage now change from Application Error to We're sorry, but something went wrong. We've been notified about this issue and we'll take a look at it shortly. ------what this means? It is my problem or heroku's problem? – Katelynn ruan Jan 16 '12 at 19:34
0

Please following steps for deploy on heroku server

First please remove the gem ='sqlite3' from Gemfile and add gem = 'pg'

Run this command on Project path: bundle install

git add .

git commit -am "add pg on gem file"

git push heroku master