我在做Ruby on Rails Tutorial.前三章使用SQLite,但後來它建議在開發中使用PostgreSQL以便更容易部署Heroku。在編輯我的database.yml
和Gemfile
以使用pg代替sqlite3後,它似乎能夠工作 - 除了使用Rake運行測試時。它彈出一個AdapterNotSpecified
錯誤。Rails/ActiveRecord - AdapterNotSpecified,即使它是
C:/Ruby/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-4.0.0/lib/active_record/ connection_adapters/connection_specification.rb:52:in resolve_hash_connection': database configuration does not specify adapter (ActiveRecord::AdapterNotSpecif ied)
等
的database.yml中指定一個適配器,就像這樣:
development:
adapter: postgresql
host: localhost
username: nekkoru
password: derpderp
database: development
encoding: UTF8
這是怎麼回事?我在Windows 7 x64,Ruby 1.9.3,Rails 4.0.0,PostgreSQL 9.3.0.1。
現在我覺得愚蠢。這當然有效。謝謝:) – Nekkoru
這非常有幫助。我沒有意識到rake任務會自動完成開發/測試。 –