Reputation: 7379
I just started a Rails 4 app from scratch with the intention to use Postgres. I went and changed the database.yml file to the following:
development:
adapter: postgresql
encoding: unicode
database: personalapi_dev
pool: 5
username: nickoneill
password:
host: localhost
# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test: &test
adapter: postgresql
encoding: unicode
database: personalapi_test
pool: 5
username: nickoneill
password:
host: localhost
Yet when I run rake db:create
it gives me the following error:
uninitialized constant ActiveRecord::ConnectionAdapters::PostgreSQLAdapter::PG
/Users/nickoneill/.rvm/gems/ruby-2.0.0-p247@personalapi/gems/activerecord-4.0.0/lib/active_record/connection_adapters/postgresql_adapter.rb:562:in `active?'
/Users/nickoneill/.rvm/gems/ruby-2.0.0-p247@personalapi/gems/activerecord-4.0.0/lib/active_record/connection_adapters/abstract_adapter.rb:360:in `verify!'
/Users/nickoneill/.rvm/gems/ruby-2.0.0-p247@personalapi/gems/activerecord-4.0.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:458:in `block in checkout_and_verify'
/Users/nickoneill/.rvm/gems/ruby-2.0.0-p247@personalapi/gems/activesupport-4.0.0/lib/active_support/callbacks.rb:373:in `_run__1536634998624253346__checkout__callbacks'
/Users/nickoneill/.rvm/gems/ruby-2.0.0-p247@personalapi/gems/activesupport-4.0.0/lib/active_support/callbacks.rb:80:in `run_callbacks'
I've tried everything from upgrading the Postgres gem, making sure Postgres is running, etc, yet not sure why it's not working. I have other rails apps (including Rails 4) on my computer that run just fine yet this new one won't work. Any ideas?
Update
Here's my gemfile:
source 'https://rubygems.org'
ruby "2.0.0"
# gem 'bootstrap-sass', '~> 2.3.2'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.0.0'
gem 'addressable'
#
# Error handling
#
gem "sentry-raven" #, :git => "https://github.com/getsentry/raven-ruby.git"
#
# Sidekiq gems
#
gem 'sidekiq' , '2.5.4'
gem 'redis' , '~> 3.0'
gem 'unicorn' , '~> 4.5'
# For sidekiq interface
#gem 'sinatra', require: false
gem 'slim'
gem 'sinatra', '>= 1.3.0', :require => nil
# json parsing
gem 'oj' , '2.0.1'
# templates
gem 'haml'
# file storage
# gem "paperclip", "~> 3.1"
# gem 'aws-sdk', '1.8.0'
# Use postgres as the database for Active Record
gem 'pg'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 4.0.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .js.coffee assets and views
gem 'coffee-rails', '~> 4.0.0'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 1.2'
group :doc do
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', require: false
end
group :development , :test do
gem "better_errors"
gem 'fakeweb'
gem 'rspec-rails', '2.12.2'
gem 'shoulda-matchers'
gem 'guard-rspec'
end
group :test do
#gem "cucumber-rails", ">= 1.3.0"
gem 'database_cleaner'
gem 'factory_girl_rails' , '~> 4.0'
gem 'capybara'
gem 'guard-spork'
gem 'spork'
gem "launchy"
gem 'rb-fsevent', '~> 0.9.1'
gem 'faker'
gem 'annotate'
gem 'simplecov'
gem 'guard-rspec'
gem 'growl'
gem 'rb-fsevent', '~> 0.9.1'
end
Upvotes: 2
Views: 1625
Reputation: 4170
From my experience updating the Gemfile to gem 'pg', '0.15.1' solved the problem.
Upvotes: 7