I want to deploy a spree app to heroku and in order to do that I need to precompile my assets locally I did
heroku addons:create heroku-postgresql
then I added config/application.rb
config.assets.initialize_on_precompile = false
my database.yaml file is
default: &default
adapter: postgresql
encoding: unicode
pool: 5
development:
<<: *default
host: localhost
database: anzels_development
username: anzels
password: 1234
test:
<<: *default
host: localhost
database: anzels_test
username: anzels
password: 1234
production:
adapter: postgresql
encoding: unicode
database: anzels_production
pool: 5
password:
and whenever I run
sumeet@sumi-pc:~/anzels$ rake assets:precompile RAILS_ENV=production
I get an error rake aborted!
ActiveRecord::NoDatabaseError: FATAL: role "sumeet" does not exist
/home/sumeet/anzels/config/environment.rb:5:in `<top (required)>'
PG::ConnectionBad: FATAL: role "sumeet" does not exist
/home/sumeet/anzels/config/environment.rb:5:in `<top (required)>'
Tasks: TOP => environment
(See full trace by running task with --trace)
config/enviormenr.rb
# Load the Rails application.
require File.expand_path('../application', __FILE__)
# Initialize the Rails application.
Rails.application.initialize!
please help
In local computer you are trying to run
rake assets:precompile RAILS_ENV=production
but this requires your local compute to have config/database.yml with the config mentioned by @thieu-nguyen
so add the following in
username: $PRODUCTION_DB_USER
password: $PRODUCTION_DB_PASS
under production in config/database.yml
then add the environment for you local computer as
PRODUCTION_DB_USER=anzels
PRODUCTION_DB_PASS=1234
and for heroku as
PRODUCTION_DB_USER=user
PRODUCTION_DB_PASS="" (empty)
username: anzels
password: 1234
to production in config/database.yml **JUST BEFORE assests precompilation ** then run command
git checkout config/database.yml
JUST BEFORE GIT COMMIT command the idea is to not to commit the username and password but temporarily edit it for assests precompilation purpose only
Please add username
and password
to production config in database.yml
or you need to create new role for postgres with name "sumeet".
production:
adapter: postgresql
encoding: unicode
database: anzels_production
pool: 5
username: anzels
password: 1234
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.