2

I'm trying to teach myself ruby on rails and I'm trying to create a simple application to start with. I'm following the tutorial at http://guides.rubyonrails.org/getting_started.html#creating-a-new-rails-project but am having difficulty starting the server. When I try start up the server and go to the localhost,

Could not load 'active_record/connection_adapters/sqlite3_adapter'. Make sure that the adapter in
config/database.yml is valid. If you use an adapter other than 'mysql', 'mysql2', 'postgresql' or
'sqlite3' add the necessary adapter gem to the Gemfile.

I'm tried to look up a solution/reason why this happens on other questions but to no avail.

My Gemfile looks like this

source 'https://rubygems.org'

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.1.6'
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
# 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. Read more:
https://github.com/rails/turbolinks
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

# 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]

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin]

I'm using Ruby 2.1.3

and when I type

gem list

I find I'm running rails 4.1.6 sqlite3 (1.3.9 x86-mingw32)

Can anyone point me in the right direction?

user3369427
  • 425
  • 6
  • 14
  • Possible duplicate of [Could not load 'active\_record/connection\_adapters/sqlite3\_adapter'](http://stackoverflow.com/questions/18277968/could-not-load-active-record-connection-adapters-sqlite3-adapter) – mlt May 25 '16 at 20:49

4 Answers4

0

Make sure your config/database.yml has an appropriate database driver set for current environment:

development:
  adapter: sqlite3 # check if you have sqlite3 here
  encoding: ...
  database: ...
  pool: ...
  username: ...
  password: ...

Also don't forget to set it for all other environments you want to use sqlite3 in.

Michael Radionov
  • 12,859
  • 1
  • 55
  • 72
0

I've never used sqlite but from the error I'm guessing you have a line in database.yml that says:

adapter: sqlite3_adapter

that should instead be:

adapter: sqlite3

Edit: ninja'd

jcm
  • 1,781
  • 1
  • 15
  • 27
0

You can put your sqlite3 gem to development in Gemfile

group :development do
gem 'sqlite3'
//*Your other gem to only development
end

-1

wrong adapter in your database.yml file. use this:

adapter: sqlite3
neha
  • 27
  • 2