6

I'm trying to install ROR on my notebook (Debian Wheezy 64 bit).

On first I had this issue (enter link description here ) solved by the first answer.

Now the rails server starts, but surfing on the browser at localhost:3000 I get the following error:

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've installed ruby 2.0.0 compiling the source code, no errors or mistakes. Then I've installed some needed libraries (sqlite3, libsqlite3-dev )...

Here is my 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'

And in my 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

My gem version:

ruby 2.0.0
rails 4.0.0
sqlite 1.3.7
4

2 回答 2

12

今天在 Sinatra 中运行 rake db:create_migration 时遇到了这个错误。我的错误是在 app.rb 中错误地指定了“sqlite:”数据库类型,而它应该是“sqlite 3 :”。例子:

错误的:

set :database, 'sqlite:name.db'

正确的:

set :database, 'sqlite3:name.db'
于 2014-04-23T16:19:39.567 回答
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 并搞砸了我的 rails 环境。哎哟。

于 2013-09-15T23:43:08.040 回答