无法加载'active_record / connection_adapters / sqlite3_adapter'

时间:2013-08-16 16:25:11

标签: ruby-on-rails sqlite

我正在尝试在我的笔记本上安装ROR(Debian Wheezy 64位)。

首先,我在第一个答案中解决了这个问题(enter link description here)。

现在rails服务器启动了,但是在localhost:3000浏览器上我收到以下错误:

  

无法加载'active_record / connection_adapters / sqlite3_adapter'。确保config / database.yml中的适配器有效。如果您使用“mysql”,“mysql2”,“postgresql”或“sqlite3”以外的适配器,请将必要的适配器gem添加到Gemfile中。

我已经安装了ruby 2.0.0编译源代码,没有错误或错误。 然后我安装了一些必需的库(sqlite3,libsqlite3-dev)......

这是我的GemFile:

'https://rubygems.org'

-# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.0.0'

-# Use sqlite3 as the database for Active Record
gem 'sqlite3'

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

-# Use ActiveModel has_secure_password
-# gem 'bcrypt-ruby', '~> 3.0.0'

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

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

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

gem 'execjs'
gem 'therubyracer'

在我的database.yml中:

-# SQLite version 3.x
-#   gem install sqlite3
-#
-#   Ensure the SQLite 3 gem is defined in your Gemfile
-#   gem 'sqlite3'
development:
  adapter: sqlite3
  database: db/development.sqlite3
  pool: 5
  timeout: 5000

我的宝石版:

ruby 2.0.0
rails 4.0.0
sqlite 1.3.7

2 个答案:

答案 0 :(得分:12)

今天在运行rake db:create_migration时遇到了在Sinatra玩的错误。我的错误是错误地指定了一个" sqlite:" app.rb中的数据库类型应该是" sqlite 3 :"。例如:

错误:

set :database, 'sqlite:name.db'

正确的:

set :database, 'sqlite3:name.db'

答案 1 :(得分:1)

我今天刚刚解决这个问题。尝试运行rake db:create或rake db:migrate或运行服务器时出现的错误略有不同:

/Users/lisa/.rvm/gems/ruby-1.9.3-p448/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in `require': Could not load 'active_record/connection_adapters/sqlite_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. (LoadError)

请注意,它正在尝试加载sqlite_adapter,而不是sqlite3_adapter,尽管我的database.yml文件有效并且其中包含'sqlite3'。我对我的database.yml做了各种各样的事情,这让我意识到无论我尝试什么(例如postgresql),rails仍然试图加载sqlite。我终于环顾四周寻找覆盖database.yml的东西并发现它:

$ env | grep sqlite

DATABASE_URL=sqlite:////Users/lisa/dev/mango/devdb.sqlite

这是为了玩django并且搞砸我的铁轨环境。哎哟。