0

尝试运行 rails 时出现错误:“请安装 sqlite3 适配器:gem install activerecord-sqlite3-adapter

已经尝试过捆绑更新和捆绑安装,似乎在我将应用程序推送到heroku之后发生(对另一个应用程序做了同样的事情并得到了同样的错误,所以重新开始)

尝试创建控制器,但错误不断出现。照它说的做了并尝试了命令“gem install activerecord-sqlite3-adapter”并得到以下信息:“在任何存储库中都找不到有效的 gem 'activerecord-sqlite3-adapter' (>= 0)”

并将 gem 添加到 gemfile 中,然后运行 ​​'bundle install' 但没有任何区别

已尝试通过运行以下两个命令再次创建 sqlite db:

bundle exec rake db:create rake db:mirgrate

两者都没有任何区别。使用以下 ruby​​ 版本:ruby 1.9.3p125

使用以下 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


# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
  adapter: sqlite3
  database: db/test.sqlite3
  pool: 5
  timeout: 5000

production:
  adapter: sqlite
  database: db/production.sqlite3
  pool: 5
  timeout: 5000

Gemfile如下:

source 'https://rubygems.org'

gem 'rails', '3.2.11'

# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'

#sqlite for dev
group :development do
 gem 'sqlite3'
end

#PG for Heroku

group :production do
  gem 'pg'
end

gem 'bootstrap-sass'
gem 'devise'
gem "rails_best_practices"

#administration:
gem 'activeadmin'

# Gems used only for assets and not required
# in production environments by default.
group :assets do
  gem 'sass-rails',   '~> 3.2.3'
  gem 'coffee-rails', '~> 3.2.1'

  # See https://github.com/sstephenson/execjs#readme for more supported runtimes
  # gem 'therubyracer', :platforms => :ruby

  gem 'uglifier', '>= 1.0.3'
end

gem 'jquery-rails'

整个错误如下所示:

C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/bundler-1.2.3/lib/bundler/rubygems_integration.rb:147:in `block in replace_gem'
te3-adapter` (sqlite3 is not part of the bundle. Add it to Gemfile.) (LoadError)
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-3.2.11/lib/active_record/connection_adapters/sqlite3_
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:251:in `re
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:251:in `bl
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:236:in `lo
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:251:in `re
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-3.2.11/lib/active_record/connection_adapters/abstract
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-3.2.11/lib/active_record/connection_adapters/abstract
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-3.2.11/lib/active_record/connection_adapters/abstract
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-3.2.11/lib/active_record/connection_adapters/abstract
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-3.2.11/lib/active_record/railtie.rb:82:in `block (2 l
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-3.2.11/lib/active_support/lazy_load_hooks.rb:36:in `
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-3.2.11/lib/active_support/lazy_load_hooks.rb:36:in `
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-3.2.11/lib/active_support/lazy_load_hooks.rb:26:in `
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-3.2.11/lib/active_support/lazy_load_hooks.rb:25:in `
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-3.2.11/lib/active_support/lazy_load_hooks.rb:25:in `
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-3.2.11/lib/active_record/railtie.rb:74:in `block in <
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.11/lib/rails/initializable.rb:30:in `instance_exec'
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.11/lib/rails/initializable.rb:30:in `run'
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.11/lib/rails/initializable.rb:55:in `block in run_ini
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.11/lib/rails/initializable.rb:54:in `each'
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.11/lib/rails/initializable.rb:54:in `run_initializers
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.11/lib/rails/application.rb:136:in `initialize!'
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.11/lib/rails/railtie/configurable.rb:30:in `method_mi
        from C:/Users/Scotty_W7/Dropbox/Rails Apps/imagemoose/config/environment.rb:5:in `<top (required)>'
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:251:in `re
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:251:in `bl
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:236:in `lo
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:251:in `re
        from C:/Users/Scotty_W7/Dropbox/Rails Apps/imagemoose/config.ru:3:in `block in <main>'
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rack-1.4.5/lib/rack/builder.rb:51:in `instance_eval'
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rack-1.4.5/lib/rack/builder.rb:51:in `initialize'
        from C:/Users/Scotty_W7/Dropbox/Rails Apps/imagemoose/config.ru:in `new'
        from C:/Users/Scotty_W7/Dropbox/Rails Apps/imagemoose/config.ru:in `<main>'
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rack-1.4.5/lib/rack/builder.rb:40:in `eval'
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rack-1.4.5/lib/rack/builder.rb:40:in `parse_file'
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rack-1.4.5/lib/rack/server.rb:200:in `app'
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.11/lib/rails/commands/server.rb:46:in `app'
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rack-1.4.5/lib/rack/server.rb:304:in `wrapped_app'
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rack-1.4.5/lib/rack/server.rb:254:in `start'
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.11/lib/rails/commands/server.rb:70:in `start'
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.11/lib/rails/commands.rb:55:in `block in <top (requir
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.11/lib/rails/commands.rb:50:in `tap'
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.11/lib/rails/commands.rb:50:in `<top (required)>'
        from script/rails:6:in `require'
        from script/rails:6:in `<main>'
4

2 回答 2

1

您必须需要sqlite adapter运行您的应用程序。
要安装适配器,只需打开命令提示符并键入

gem install activerecord-sqlite3-adapter

稍等片刻即可安装适配器。安装后尝试运行您的应用程序..

于 2013-03-18T10:54:09.797 回答
0

您是否将 config/database.yml 更改为使用 postgres 而不是 sqlite?

于 2013-11-23T19:36:46.213 回答