title: rake aborted! Gem::LoadError: Specified 'postgresql' for database adapter
body: <p>I'm new to Rails. Everything was OK till I change my Gemfile to be able to use heroku. I have pg in my Gemfile but I still get this error while running <code>bundle exec rake test</code></p>
  
  <p>I cannot use rails console either.</p>
  
  <pre><code>    rake aborted!
  Gem::LoadError: Specified 'postgresql' for database adapter, but the gem is not loaded. Add `gem 'pg'` to your Gemfile (and ensure its version is at the minimum required by ActiveRecord).
  /home/rihanna/.rvm/gems/ruby-2.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/connection_specification.rb:177:in `rescue in spec'
  /home/rihanna/.rvm/gems/ruby-2.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/connection_specification.rb:174:in `spec'
  /home/rihanna/.rvm/gems/ruby-2.2.0/gems/activerecord-4.2.0/lib/active_record/connection_handling.rb:50:in `establish_connection'
  /home/rihanna/.rvm/gems/ruby-2.2.0/gems/activerecord-4.2.0/lib/active_record/railtie.rb:120:in `block (2 levels) in &lt;class:Railtie&gt;'
  /home/rihanna/.rvm/gems/ruby-2.2.0/gems/activesupport-4.2.0/lib/active_support/lazy_load_hooks.rb:38:in `instance_eval'
  /home/rihanna/.rvm/gems/ruby-2.2.0/gems/activesupport-4.2.0/lib/active_support/lazy_load_hooks.rb:38:in `execute_hook'
  /home/rihanna/.rvm/gems/ruby-2.2.0/gems/activesupport-4.2.0/lib/active_support/lazy_load_hooks.rb:45:in `block in run_load_hooks'
  /home/rihanna/.rvm/gems/ruby-2.2.0/gems/activesupport-4.2.0/lib/active_support/lazy_load_hooks.rb:44:in `each'
  /home/rihanna/.rvm/gems/ruby-2.2.0/gems/activesupport-4.2.0/lib/active_support/lazy_load_hooks.rb:44:in `run_load_hooks'
  /home/rihanna/.rvm/gems/ruby-2.2.0/gems/activerecord-4.2.0/lib/active_record/base.rb:316:in `&lt;module:ActiveRecord&gt;'
  /home/rihanna/.rvm/gems/ruby-2.2.0/gems/activerecord-4.2.0/lib/active_record/base.rb:26:in `&lt;top (required)&gt;'
  /home/rihanna/.rvm/gems/ruby-2.2.0/gems/activerecord-4.2.0/lib/active_record/migration.rb:411:in `maintain_test_schema!'
  /home/rihanna/.rvm/gems/ruby-2.2.0/gems/railties-4.2.0/lib/rails/test_help.rb:19:in `&lt;top (required)&gt;'
  /home/rihanna/.rvm/gems/ruby-2.2.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:274:in `require'
  /home/rihanna/.rvm/gems/ruby-2.2.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:274:in `block in require'
  /home/rihanna/.rvm/gems/ruby-2.2.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:240:in `load_dependency'
  /home/rihanna/.rvm/gems/ruby-2.2.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:274:in `require'
  /home/rihanna/workspace/sample_app/test/test_helper.rb:3:in `&lt;top (required)&gt;'
  /home/rihanna/workspace/sample_app/test/controllers/static_pages_controller_test.rb:1:in `require'
  /home/rihanna/workspace/sample_app/test/controllers/static_pages_controller_test.rb:1:in `&lt;top (required)&gt;'
  /home/rihanna/.rvm/gems/ruby-2.2.0/gems/railties-4.2.0/lib/rails/test_unit/sub_test_task.rb:114:in `require'
  /home/rihanna/.rvm/gems/ruby-2.2.0/gems/railties-4.2.0/lib/rails/test_unit/sub_test_task.rb:114:in `block (3 levels) in define'
  /home/rihanna/.rvm/gems/ruby-2.2.0/gems/railties-4.2.0/lib/rails/test_unit/sub_test_task.rb:114:in `each'
  /home/rihanna/.rvm/gems/ruby-2.2.0/gems/railties-4.2.0/lib/rails/test_unit/sub_test_task.rb:114:in `block (2 levels) in define'
  /home/rihanna/.rvm/gems/ruby-2.2.0/gems/railties-4.2.0/lib/rails/test_unit/sub_test_task.rb:113:in `each'
  /home/rihanna/.rvm/gems/ruby-2.2.0/gems/railties-4.2.0/lib/rails/test_unit/sub_test_task.rb:113:in `block in define'
  /home/rihanna/.rvm/gems/ruby-2.2.0/gems/railties-4.2.0/lib/rails/test_unit/sub_test_task.rb:20:in `invoke_rake_task'
  /home/rihanna/.rvm/gems/ruby-2.2.0/gems/railties-4.2.0/lib/rails/test_unit/testing.rake:8:in `block in &lt;top (required)&gt;'
  Gem::LoadError: pg is not part of the bundle. Add it to Gemfile.
  /home/rihanna/.rvm/gems/ruby-2.2.0/gems/bundler-1.8.5/lib/bundler/rubygems_integration.rb:261:in `block in replace_gem'
  /home/rihanna/.rvm/gems/ruby-2.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/postgresql_adapter.rb:16:in `&lt;top (required)&gt;'
  /home/rihanna/.rvm/gems/ruby-2.2.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:274:in `require'
  /home/rihanna/.rvm/gems/ruby-2.2.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:274:in `block in require'
  /home/rihanna/.rvm/gems/ruby-2.2.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:240:in `load_dependency'
  /home/rihanna/.rvm/gems/ruby-2.2.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:274:in `require'
  /home/rihanna/.rvm/gems/ruby-2.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/connection_specification.rb:175:in `spec'
  /home/rihanna/.rvm/gems/ruby-2.2.0/gems/activerecord-4.2.0/lib/active_record/connection_handling.rb:50:in `establish_connection'
  /home/rihanna/.rvm/gems/ruby-2.2.0/gems/activerecord-4.2.0/lib/active_record/railtie.rb:120:in `block (2 levels) in &lt;class:Railtie&gt;'
  /home/rihanna/.rvm/gems/ruby-2.2.0/gems/activesupport-4.2.0/lib/active_support/lazy_load_hooks.rb:38:in `instance_eval'
  /home/rihanna/.rvm/gems/ruby-2.2.0/gems/activesupport-4.2.0/lib/active_support/lazy_load_hooks.rb:38:in `execute_hook'
  /home/rihanna/.rvm/gems/ruby-2.2.0/gems/activesupport-4.2.0/lib/active_support/lazy_load_hooks.rb:45:in `block in run_load_hooks'
  /home/rihanna/.rvm/gems/ruby-2.2.0/gems/activesupport-4.2.0/lib/active_support/lazy_load_hooks.rb:44:in `each'
  /home/rihanna/.rvm/gems/ruby-2.2.0/gems/activesupport-4.2.0/lib/active_support/lazy_load_hooks.rb:44:in `run_load_hooks'
  /home/rihanna/.rvm/gems/ruby-2.2.0/gems/activerecord-4.2.0/lib/active_record/base.rb:316:in `&lt;module:ActiveRecord&gt;'
  /home/rihanna/.rvm/gems/ruby-2.2.0/gems/activerecord-4.2.0/lib/active_record/base.rb:26:in `&lt;top (required)&gt;'
  /home/rihanna/.rvm/gems/ruby-2.2.0/gems/activerecord-4.2.0/lib/active_record/migration.rb:411:in `maintain_test_schema!'
  /home/rihanna/.rvm/gems/ruby-2.2.0/gems/railties-4.2.0/lib/rails/test_help.rb:19:in `&lt;top (required)&gt;'
  /home/rihanna/.rvm/gems/ruby-2.2.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:274:in `require'
  /home/rihanna/.rvm/gems/ruby-2.2.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:274:in `block in require'
  /home/rihanna/.rvm/gems/ruby-2.2.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:240:in `load_dependency'
  /home/rihanna/.rvm/gems/ruby-2.2.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:274:in `require'
  /home/rihanna/workspace/sample_app/test/test_helper.rb:3:in `&lt;top (required)&gt;'
  /home/rihanna/workspace/sample_app/test/controllers/static_pages_controller_test.rb:1:in `require'
  /home/rihanna/workspace/sample_app/test/controllers/static_pages_controller_test.rb:1:in `&lt;top (required)&gt;'
  /home/rihanna/.rvm/gems/ruby-2.2.0/gems/railties-4.2.0/lib/rails/test_unit/sub_test_task.rb:114:in `require'
  /home/rihanna/.rvm/gems/ruby-2.2.0/gems/railties-4.2.0/lib/rails/test_unit/sub_test_task.rb:114:in `block (3 levels) in define'
  /home/rihanna/.rvm/gems/ruby-2.2.0/gems/railties-4.2.0/lib/rails/test_unit/sub_test_task.rb:114:in `each'
  /home/rihanna/.rvm/gems/ruby-2.2.0/gems/railties-4.2.0/lib/rails/test_unit/sub_test_task.rb:114:in `block (2 levels) in define'
  /home/rihanna/.rvm/gems/ruby-2.2.0/gems/railties-4.2.0/lib/rails/test_unit/sub_test_task.rb:113:in `each'
  /home/rihanna/.rvm/gems/ruby-2.2.0/gems/railties-4.2.0/lib/rails/test_unit/sub_test_task.rb:113:in `block in define'
  /home/rihanna/.rvm/gems/ruby-2.2.0/gems/railties-4.2.0/lib/rails/test_unit/sub_test_task.rb:20:in `invoke_rake_task'
  /home/rihanna/.rvm/gems/ruby-2.2.0/gems/railties-4.2.0/lib/rails/test_unit/testing.rake:8:in `block in &lt;top (required)&gt;'
  Tasks: TOP =&gt; test:run
  </code></pre>
  
  <p>and this is my Gemfile:</p>
  
  <pre><code>source 'https://rubygems.org'
  
  
  # Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
  gem 'rails', '4.2.0'
  # Use sqlite3 as the database for Active Record
  
  #gem 'pg'
  # Use SCSS for stylesheets
  gem 'sass-rails', '~&gt; 5.0'
  # Use Uglifier as compressor for JavaScript assets
  gem 'uglifier', '&gt;= 1.3.0'
  # Use CoffeeScript for .coffee assets and views
  gem 'coffee-rails', '~&gt; 4.1.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', '~&gt; 2.0'
  # bundle exec rake doc:rails generates the API under doc/api.
  gem 'sdoc', '~&gt; 0.4.0', group: :doc
  
  # Use ActiveModel has_secure_password
  # gem 'bcrypt', '~&gt; 3.1.7'
  
  # Use Unicorn as the app server
  # gem 'unicorn'
  
  # Use Capistrano for deployment
  # gem 'capistrano-rails', group: :development
  
  group :development, :test do
    # Call 'byebug' anywhere in the code to stop execution and get a debugger console
    gem 'byebug'
    gem 'sqlite3'
    # Access an IRB console on exception pages or by using &lt;%= console %&gt; in views
    gem 'web-console', '~&gt; 2.0'
  
    # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
    gem 'spring'
  end
  
  
  group :production do
    gem 'pg',             '0.18.1'
    gem 'rails_12factor', '0.0.2'
  
  end
  </code></pre>