Reputation: 733
Cannot connect to database through active record in my Sinatra app on Windows 10, no issue on OSX but I would still like to be able to develop from my Windows machine.
Full error: C:/Ruby23-x64/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:120:in `require': Could not load 'active_record/connection_adapters/postgresql_adapter'. Make sure that the adapter in config/database.yml is valid. If you use an adapter other than 'mysql2', 'postgresql' or 'sqlite3' add the necessary adapter gem to the Gemfile. (LoadError)
Ruby version: 2.3.1
gem 'pg'
^^ is included in the Gemfile
require 'sinatra/activerecord'
^^ in app.rb
Not relevant: Could not load 'active_record/connection_adapters/postgresql_adapter'
Environments.rb :
configure :development do
ActiveRecord::Base.establish_connection(
:adapter => db.scheme == 'postgres' ? 'postgresql' : db.scheme,
:host => 'localhost',
:username => 'postgres',
:password => '******',
:database => '******',
:port => 5432
:encoding => 'utf8'
)
end
database.yml: development: adapter: postgresql encoding: unicode database: Same as environments.rb pool: 5 username: Same as environments.rb password: Same as environments.rb
Upvotes: 0
Views: 1712
Reputation: 733
I'm not sure why exactly, but Ruby version 2.3.1 doesn't do well with Sinatra on Windows. I downgraded to Ruby 2.2.5 and kept activeRecord '5.0.0' and everything worked fine.
Upvotes: 1
Reputation: 1984
Your adapter in enviroments.rb should just be postgresql
. Nothing else.
Upvotes: 0