2014-10-04 122 views
2

我想教自己在rails上的ruby,我試圖創建一個簡單的應用程序開始。我正在按照http://guides.rubyonrails.org/getting_started.html#creating-a-new-rails-project的教程進行操作,但是無法啓動服務器。當我嘗試啓動服務器並轉到本地主機,無法啓動rails服務器 - sqlite3適配器錯誤

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. 

我試圖尋找一個解決方案/之所以出現這種情況的其他問題,但無濟於事。

我的Gemfile看起來像這樣

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] 

我使用 紅寶石2.1.3

,當我鍵入

寶石列表

我發現我正在運行 rails 4.1.6 sqlite3(1.3.9 x86-mingw32)

任何人都可以指向正確的方向嗎?

+0

[無法加載'active \ _record/connection \ _adapters/sqlite3 \ _adapter'](http: //stackoverflow.com/questions/18277968/could-not-load-active-record-connection-adapters-sqlite3-adapter) – mlt 2016-05-25 20:49:10

回答

0

確保您config/database.yml有適當的數據庫驅動程序當前的環境設置:

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

也不要忘記設置爲你希望使用的sqlite3的所有其他環境

0

我從未使用過的SQLite但是從錯誤中我猜你在database.yml一條線,說:

adapter: sqlite3_adapter 

應改爲:

adapter: sqlite3 

編輯:在您的database.yml文件ninja'd

-2

正確的適配器。 使用這樣的:

adapter: sqlite3 
0

你可以把你的sqlite3寶石發展的Gemfile

組:發展做
寶石 'sqlite3的'
// *您其他寶石只有發展
end