耙资产:预编译RAILS

编程入门 行业动态 更新时间:2024-10-24 20:11:42
本文介绍了耙资产:预编译RAILS_ENV =生产错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想将一个狂欢应用程序部署到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

本文发布于:2023-10-28 13:27:29,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1536764.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:资产   RAILS

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!