1

having a problem with a heroku upload. Quite new to RoR so please excuse the beginners question.

I'm following the Ruby on Rails Tutorial (http://ruby.railstutorial.org), and after the scaffolding, I type heroku rake db:migrate and get the following error:

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

Tasks: TOP => db:migrate => db:load_config (See full trace by running task with --trace)

First time around, no problem, but this time I'm getting this error. Any ideas?

David Archer
  • 2,008
  • 4
  • 26
  • 31
  • Sounds like you need to run the command `gem install activerecord-postgresql-adapter`. – Alex Sep 20 '11 at 22:38
  • @Alex I have indeed tried that, and that pulls up the error ERROR: Could not find a valid gem 'activerecord-postgresql-adapter' (>= 0) in any repository ERROR: Possible alternatives: activerecord-jdbcpostgresql-adapter, activerecord-postgis-adapter, activerecord-jdbcmssql-adapter, activerecord-jdbcmysql-adapter, activerecord-postgresql-cursors – David Archer Sep 20 '11 at 22:41
  • Have you added `pg` to your Gemfile and run `bundle install`? – sscirrus Sep 20 '11 at 22:42
  • @sscirrus yes, and Using pg (0.11.0) is in there while installing. – David Archer Sep 20 '11 at 22:45
  • @Alex No, I'm using Rails 3.1.0 – David Archer Sep 20 '11 at 22:45
  • Does [this question](http://stackoverflow.com/questions/6410623/heroku-error-when-launch-rails3-1-app-missing-postgres-gem) hold any helpful answers? There are [a few more](http://www.google.co.uk/search?gcx=w&sourceid=chrome&ie=UTF-8&q=pg+is+not+part+of+the+bundle+heroku) related questions – Alex Sep 20 '11 at 23:08
  • Well, I seem to have fixed it by adding 'gem pg' to the Gemfile and destroying and creating the heroku account. I got the rake working, which is great :) Unfortunately, it now just sends me to an Error 500 page. Any ideas? – David Archer Sep 20 '11 at 23:51
  • check your logs, `heroku logs` – John Beynon Sep 21 '11 at 06:50

2 Answers2

2

By default, a new Rails application is configured to use the SQLite3 database. Heroku doesn't support SQLite3, you must use PostgreSQL.

You have two alternatives:

  1. Keep using SQLite3 in development and test, and switch to PostgreSQL in production.
  2. Switch to PostgreSQL

Either ways, you need to add the pg gem to your Gemfile (assuming you are using Rails 3) and remove sqlite3.

# Gemfile
gem 'pg'

If you want to use Sqlite3 in development and test

# Gemfile
group :development, :test do
  gem 'sqlite3'
end

group :production do
  gem 'pg'
end

You might also need to change your database.yml configuration accordingly.

Simone Carletti
  • 173,507
  • 49
  • 363
  • 364
2

Not quite the answer Simone, but after more digging, the answer finally came up. I needed to do the following:

In the gemfile, I needed to change gem 'sqlite3' to:

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

group :production do   gem 'pg' end

and then I needed to heroku create --stack cedar.

Thanks for your help everyone regardless, and I hope this helps someone in the future.

David Archer
  • 2,008
  • 4
  • 26
  • 31