2014-04-09 14 views
7

W database.yml (szyny generowane domyślnego pliku):grabie o adapterze bazy niezgodne z database.yml

default: &default 
    adapter: sqlite3 
    pool: 5 
    timeout: 5000 

development: 
    <<: *default 
    database: db/development.sqlite3 

test: 
    <<: *default 
    database: db/test.sqlite3 

production: 
    <<: *default 
    database: db/production.sqlite3 

Uruchamiając rake about, mam ten błąd:

Gem::LoadError: Specified 'postgresql' for database adapter, but the gem is not loaded.  
Add `gem 'pg'` to your Gemfile (and ensure its version is at the minimum required by  
ActiveRecord). 

Gdybym dodać pg gem, następnie rake about daje to wyjście:

About your application's environment 
Ruby version    2.1.0-p0 (x86_64-darwin13.0) 
RubyGems version   2.2.2 
Rack version    1.5 
Rails version    4.1.0 
JavaScript Runtime  Node.js (V8) 
Active Record version  4.1.0 
Action Pack version  4.1.0 
Action View version  4.1.0 
Action Mailer version  4.1.0 
Active Support version 4.1.0 
Middleware    Rack::Sendfile, ActionDispatch::Static, Rack::Lock, # <ActiveSupport::Cache::Strategy::LocalCache::Middleware:0x007f8043154a30>, Rack::Runtime, Rack::MethodOverride, ActionDispatch::RequestId, Rails::Rack::Logger, ActionDispatch::ShowExceptions, ActionDispatch::DebugExceptions, ActionDispatch::RemoteIp, ActionDispatch::Reloader, ActionDispatch::Callbacks, ActiveRecord::Migration::CheckPending, ActiveRecord::ConnectionAdapters::ConnectionManagement, ActiveRecord::QueryCache, ActionDispatch::Cookies, ActionDispatch::Session::CookieStore, ActionDispatch::Flash, ActionDispatch::ParamsParser, Rack::Head, Rack::ConditionalGet, Rack::ETag 
Environment    development 
Database adapter   postgresql 
Database schema version 0 

Każdy pomysł, dlaczego tak się dzieje? Chcę użyć adaptera sqlite3.

+0

Czy możesz udostępnić pełną zawartość database.yml? –

+0

W database.yml twój adapter nadal określa sqlite3, zmień go na postgresql jak poniżej – andreofthecape

+0

Próbuję użyć sqlite3 jako adapter, a nie postgres. Rake mówi, że używam adaptera PostgreSQL z jakiegoś powodu. – sysofwan

Odpowiedz

9

znalazłem problem. Wygląda na to, że Rake szukał zmiennej środowiskowej DATABASE_URL (którą ustawiłem na postgres) i ma to pierwszeństwo przed plikiem database.yml. Po usunięciu zmiennej środowiskowej wszystko działa poprawnie.

+0

Hej, mam ten sam problem. Czy możesz podać mi kilka szczegółów, jak rozwiązać ten problem (jeśli nadal pamiętasz)? – Syk

0

W database.yml zmiana adapter: sqlite3 do adapter: postgresql

byłoby Należy również określić:
encoding: unicode
database: yourapp_development
pool: 5
username: your_username
password: your_password

Jeśli jest to nowa aplikacja, która grasz wokół z, ponownie uruchom nowy generator szyn, używając: rails new appname -d postgresql. Spowoduje to utworzenie aplikacji z adapterem PostgreSQL.

W twoim przypadku:

default: &default 
    adapter: postgresql 
    encoding: unicode 
    pool: 5 
    timeout: 5000 

development: 
    <<: *default 
    database: yourapp_development 
    username: your_username 
    password: your_password 

test: 
    <<: *default 
    database: yourapp_test 
    username: your_username 
    password: your_password 

production: 
    <<: *default 
    database: yourapp_production 
    username: your_username 
    password: your_password` 
+0

Twoja sugestia działa, ale próbuję użyć sqlite3 jako adaptera, a nie postgresu. Dzięki! – sysofwan

+0

Proszę poślij swój Gemfile – andreofthecape

Powiązane problemy