Closed MOPineyro closed 9 years ago
@MOPineyro It sounds like something is wrong with your database configuration. Do you have an idea of how you're setting up your database.yml?
Also, what ActiveRecord version are you using?
My database.yml is the default
defaults: &defaults
encoding: unicode
adapter: postgresql
host: <%= ENV['DATABASE_HOST'] %>
username: <%= ENV['DATABASE_USER'] %>
password: <%= ENV['DATABASE_PASSWORD'] %>
database: <%= ENV['DATABASE_NAME'] %>
production:
<<: *defaults
development:
<<: *defaults
test:
<<: *defaults
staging:
<<: *defaults
activerecord (4.0.13)
I started a fresh napa app and pushed it to heroku and it throws the same error.
Ah, if you have anything below ActiveRecord 4.1, Heroku will rewrite your database.yml:
https://devcenter.heroku.com/articles/rails-database-connection-behavior#prior-to-rails-4-1
That means you need to have your DATABASE_URL
env set, and you'll have to change your ActiveRecord setup like so:
# in your config/initializers/active_record.rb
db_config = ENV['DATABASE_URL'] || YAML.load(ERB.new(File.read('./config/database.yml')).result)[Napa.env]
db_connection = ActiveRecord::Base.establish_connection(db_config)
ActiveRecord::Base.configurations["db"] = db_connection.spec.config
This should get you on your way, assuming you have the pg
gem installed
Though, I would qualify this as a bug, since it's not working correctly out of the box. We'll figure out a way to fix the scaffolding.
Updated active record then modified the initializer like you mentioned. All good now. Thank you!
should be fixed by https://github.com/bellycard/napa/pull/234
The app runs on heroku, but when attempting to run napa console I receive the following error: