Reputation: 18716
Here's my problem:
I create a new project: rails new myapp
.
Rails applications are by default configured to use a SQLite3 database.
I execute bundle exec rake db:create
. It works and the SQLite3 database is created.
I try to create a new model (or anything else related to the database), and get the following error:
/home/dinduks/.rvm/gems/ruby-1.9.3-p194/gems/bundler-1.1.3/lib/bundler/rubygems_integration.rb:147:in
block in replace_gem': Please install the postgresql adapter:
gem install activerecord-postgresql-adapter` (pg is not part of the bundle. Add it to Gemfile.) (LoadError)
When I add a controller and an action, and try to visit it, I get this error:
ActiveRecord::ConnectionNotEstablished (ActiveRecord::ConnectionNotEstablished)
The complete stack trace can be found here: https://gist.github.com/2717365
The WEBrick server starts obviously without complaining.
I reinstalled Rails, reinstalled Ruby, used another Ruby version, reinstalled RVM... And keep getting the same error.
There is nothing related to PostgreSQL, postgres, pg or pql in my code. Not a single word.
I don't want to do what the exception suggests. I want to understand why I have this error and fix it.
So: Why is Rails asking me to install some Postgres stuff while I don't use Postgres?
Thanks!
Upvotes: 1
Views: 6308
Reputation: 18716
The problem was the DATABASE_URL
environment variable.
When ActiveRecord finds $DATABASE_URL
, it automatically uses its information, and ignores config/database.yml.
Thanks to NARKOZ for pointing this out.
(By the way, I had this environment variable set before I discover foreman, which is a great tool to manage environment variables)
Upvotes: 8