2

I am trying to use PostgreSQL instead of SQLite3 for my Rails app because PostgreSQL is required by Heroku, where I want to deploy the app. Starting my app with the Postgres flag (i.e., --databse=postgresql) works fine. However, after adding gem twitter-boostrap-rails to my Gemfile and running bundle install I get this error about SQLite3:

active_record/connection_adapters/connection_specification.rb:190:in

rescue in spec': Specified 'sqlite3' for database adapter, but the gem is not loaded. Addgem 'sqlite3'` to your Gemfile (and ensure its version is at the minimum required by ActiveRecord)

Here is my Gemfile:

source 'https://rubygems.org'

gem "therubyracer"
gem "less-rails"
gem "twitter-bootstrap-rails"


# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.1.4'
# Use postgresql as the database for Active Record
gem 'pg'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 4.0.3'
# 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.              
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0',          group: :doc

# Spring speeds up development by keeping your application running in the background.   
gem 'spring',        group: :development

# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'

# Use unicorn as the app server
# gem 'unicorn'

# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development

# Use debugger
# gem 'debugger', group: [:development, :test]

gem 'rails_12factor', group: :production>

And here is my database.yml:

----------


# PostgreSQL. Versions 8.2 and up are supported.
#
# Install the pg driver:
#   gem install pg
# On OS X with Homebrew:
#   gem install pg -- --with-pg-config=/usr/local/bin/pg_config
# On OS X with MacPorts:
#   gem install pg -- --with-pg-config=/opt/local/lib/postgresql84/bin/pg_config
# On Windows:
#   gem install pg
#       Choose the win32 build.
#       Install PostgreSQL and put its /bin directory on your path.
#
# Configure Using Gemfile
# gem 'pg'
#
default: &default
  adapter: postgresql
  encoding: unicode
  # For details on connection pooling, see rails configuration guide
  # http://guides.rubyonrails.org/configuring.html#database-pooling
  pool: 5

development:
  <<: *default

Why am I getting this error, and how do I fix the problem?

4
  • can you please clear me one thing which adapter you want to use? in gem file I see that it is pg but you told you got error of sqlite 3 Commented Jul 25, 2014 at 18:10
  • I want to use postgresql, as that is required for hosting on Heroku Commented Jul 25, 2014 at 18:20
  • check your Gemfile.lock probably its a dependency to one of the gems you installed Commented Jul 25, 2014 at 18:21
  • No sqlite3 is not listed in my Gemfile.lock Commented Jul 25, 2014 at 18:25

2 Answers 2

2

Try setting the database config for development explicitly. Looks like the database.yml is not aligned correctly.

development:
  adapter: postgresql
  encoding: utf8
  database: your_db
  host: 127.0.0.1
  pool: 5
  username: your_db_username
  password: your_db_password
Sign up to request clarification or add additional context in comments.

Comments

2

try running bundle update and then bundle exec rails s - also you are gonna need to specify more parameters in your database.yml like your host, etc. should look something like this:

development:
  adapter: postgresql
  encoding: unicode
  database: some_database_name
  pool: 5
  host: localhost
  username: your_username (or root) if just dev
  password: your_password

keep in mind since this is all dev, the security of the username/pw doesn't really matter as its not housing any important data/not accessible outside your machine

5 Comments

Every thing works until I do: "rails g bootstrap:install", I get the sqlite3 error again
try bundle exec rails g bootstrap:install
Ok that works, but why?? now Im getting "user does not exist" when I do rake db:create db:migrate
read this answer for why it works :) stackoverflow.com/questions/6588674/… as to your other error, its possibly because you have your database username/password combination wrong. Check how you installed postgresql and make a user for it
@user1020372 are you still having issues with this? Can we close this question? :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.