I'm new to Ruby on Rails. I installed Rails 4 on my Windows 8 system, and the DevKit, and installed the pg (PostgreSQL) gem.
> gem install pg ... Successfully installed pg-0.16.0-x64-mingw32 I created a new rails application:
> rails new blog -d postgresql But when I start rails server
> cd blog > rails server and navigate to the localhost:3000 in my browser, I see this error:
Gem::LoadError Specified 'postgresql' for database adapter, but the gem is not loaded. Add `gem 'pg'` to your Gemfile.
My Gemfile includes these lines:
# Use postgresql as the database for Active Record gem 'pg' Additionally, if I do
bundle install pg is not listed in the output.
If I do
require 'pg' in the Ruby console I get
=> true This question is very similar to
Rails 4 postgres bug - cannot create database because the pg gem "is missing", but it is not
but in that case the questioner realized he was using an older version of the pg gem. I have the version that was installed with gem install pg, which I assume is the most recent one.
Can anyone provide some troubleshooting guidance?
Update:
From the comment by @vinodadhikary I tried bundle update pg
which returned
Fetching gem metadata from https://rubygems.org/........... Fetching gem metadata from https://rubygems.org/.. Resolving dependencies... Using rake (10.1.0) ... Your bundle is updated! without mentioning pg.
I then tried bundle show pg, which returned
Could not find gem 'pg'. Did you mean pg? I tried running the server again, and received the same error.
Update 2
I have my config\database.yml file configured per my existing postgres database, like
development: adapter: postgresql encoding: unicode database: rails_dev pool: 5 username: postgres password: [password] host: localhost port: 5433 and likewise for test and production. Thanks Artiwarah Damrongchai for suggesting that.
bundle update pgand checkbundle show pg