【问题标题】:gem sqlite not load in gemfile rails 4gem sqlite未加载到gemfile rails 4中
【发布时间】:2014-01-08 02:53:01
【问题描述】:

我使用的是 rails 4 和 ruby​​ 2.0,但是当我在控制台中运行 rails s i 时,会出现如下错误:

/home/user/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.1/lib/active_record/connection_adapters/connection_specification.rb:58:in `rescue in resolve_hash_connection': Specified 'sqlite3' for database adapter, but the gem is not loaded. Add `gem 'sqlite3'` to your Gemfile. (Gem::LoadError)

为什么会出错?我已经将 gem 'sqlite3' 放入 gemfile 并运行 bundle install 但仍然出错,这是我的 gemfile:

ruby '2.0.0'

source 'https://rubygems.org'

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

# 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

gem 'devise'
gem "twitter-bootstrap-rails"
gem 'carrierwave'
# Use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.1.2'

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

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

group :development do
  # Use sqlite3 as the database for Active Record
  gem 'sqlite3'
end
# Use debugger
gem 'debugger', group: [:development, :test]
gem 'pg', group: [:production]

gem 'rails_12factor'

这是我的 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: sqlite3
  database: db/production.sqlite3
  pool: 5
  timeout: 5000

如果我错了请告诉我?谢谢

【问题讨论】:

    标签: sqlite ruby-on-rails-4 ruby-2.0


    【解决方案1】:

    尝试进入您的 gemfile.lock 文件并将 sqlite3 版本更改为sqlite3 (1.3.8),然后重新捆绑安装/捆绑更新

    【讨论】:

      猜你喜欢
      • 2014-04-25
      • 1970-01-01
      • 2023-03-07
      • 1970-01-01
      • 2016-01-10
      • 2019-07-04
      • 2013-10-16
      • 2011-12-19
      • 1970-01-01
      相关资源
      最近更新 更多