耙资产:预编译RAILS_ENV =生产错误 [英] rake assets:precompile RAILS_ENV=production Error
问题描述
我想将一个狂欢应用程序部署到heroku,为此,我需要在本地预编译资产 我做了
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
然后我添加了config/application.rb
then I added config/application.rb
config.assets.initialize_on_precompile = false
我的database.yaml文件是
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:
以及我每次跑步
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!
请帮助
推荐答案
在本地计算机上,您尝试运行
In local computer you are trying to run
rake资产:预编译RAILS_ENV =生产
rake assets:precompile RAILS_ENV=production
但这需要您的本地计算机具有config/database.yml,并带有@ thieu-nguyen提到的配置
but this requires your local compute to have config/database.yml with the config mentioned by @thieu-nguyen
因此请在以下内容中添加
so add the following in
用户名:$ PRODUCTION_DB_USER
username: $PRODUCTION_DB_USER
密码:$ PRODUCTION_DB_PASS
password: $PRODUCTION_DB_PASS
正在生产中 config/database.yml
然后为您的本地计算机添加环境
then add the environment for you local computer as
PRODUCTION_DB_USER = anzels
PRODUCTION_DB_USER=anzels
PRODUCTION_DB_PASS = 1234
PRODUCTION_DB_PASS=1234
,对于heroku,
PRODUCTION_DB_USER =用户
PRODUCTION_DB_USER=user
PRODUCTION_DB_PASS ="" (空)
PRODUCTION_DB_PASS="" (empty)
另一种简便方法
ANOTHER EASIER WAY IS
用户名:anzels
username: anzels
密码:1234
config/database.yml 中的生产 **仅在进行预编译之前** 然后运行命令
to production in config/database.yml **JUST BEFORE assests precompilation ** then run command
git checkout config/database.yml
git checkout config/database.yml
在执行GIT COMMIT命令之前 想法是不要提交用户名和密码,而是临时编辑它,以仅用于预编译目的
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
这篇关于耙资产:预编译RAILS_ENV =生产错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!