尝试了几个修正:Heroku / Rails 4资产预编译错误 [英] Tried several fixes: Heroku/Rails 4 Assets Precompile Error

查看:130
本文介绍了尝试了几个修正:Heroku / Rails 4资产预编译错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

看起来这是一个常见问题,所以让我先说我已经做了大量的研究。



关注 >
heroku labs:enable user-env-compile -a myapp



然后我通过运行

RAILS_ENV = production bundle exec rake assets:precompile

确保资源预编译。

他们这样做。



我也跟着这个提示,设置


config.assets.initialize_on_precompile = false



在我的config / production.rb和config / application.rb中。



此外,以下问题,我确定我已经安装了heroku gems:

  gem'rails_log_stdout',github:'heroku / rails_log_stdout'
gem'rails3_serve_static_assets',github:'heroku / rails3_serve_static_assets'

然后我确定我的路径中有 bin ,方法如下: this heroku article

然后我确定我跟着Rails 4.xx入门关于heroku的文章



我也跟着另一个答案这个问题,并将以下内容放在 application.rb production.rb

  config.serve_static_assets = true 

这里是错误I在运行时获得

 为Rails资产准备应用程序管道
运行:rake资产:预编译
rake中止!
无法连接到服务器:连接被拒绝
服务器是否在主机127.0.0.1上运行并接受端口5432上的
TCP / IP连接?

好像 config.assets.initialize_on_precompile = false 应该已经工作了,因为它看起来好像试图在预编译期间加载生产数据库。



我已经完成了所有这些更改,并且它们已被推送到掌握在 git 中。现在我该怎么办?

解决方案

好吧,对此抱歉。我想我没有推过 RAILS_ENV = production bundle exec rake assets:precompile 的效果。希望这可以成为这个问题的一些资源。



编辑



为了做到这一点,我运行 RAILS_ENV =生产捆绑销售佣金资产:预编译。然后我将它与

  git add -A 
git commit -m预编译资产
git push origin master
git push heroku master


Looks like this is a common issue, so let me begin by saying I've done a lot of research already.

Following this thread, I ran

heroku labs:enable user-env-compile -a myapp

Then I made sure that assets precompile locally by running

RAILS_ENV=production bundle exec rake assets:precompile

They do.

I also followed this tip, setting

config.assets.initialize_on_precompile = false

in my config/production.rb and config/application.rb.

Also, following this issue, I've made sure I have the heroku gems installed:

gem 'rails_log_stdout',           github: 'heroku/rails_log_stdout'
gem 'rails3_serve_static_assets', github: 'heroku/rails3_serve_static_assets'

Then I made sure I had bin in my path by following this heroku article.

Then I made sure I followed the "Getting Started with Rails 4.x.x" article on heroku.

I've also followed another answer to this question and placed the following in application.rb and production.rb

config.serve_static_assets = true

Here's the error I get when running git push heroku master:

   Preparing app for Rails asset pipeline
   Running: rake assets:precompile
   rake aborted!
   could not connect to server: Connection refused
   Is the server running on host "127.0.0.1" and accepting
   TCP/IP connections on port 5432?

It seems like config.assets.initialize_on_precompile = false should've worked, because it seems like it's trying to load the production database during precompliation.

I've made all these changes and they've been pushed to master in git. Now what should I try?

解决方案

Well, sorry about this. I guess I hadn't pushed the effects of RAILS_ENV=production bundle exec rake assets:precompile. Hopefully this serves as a number of resources for this issue.

Edit

In order to do this, I ran RAILS_ENV=production bundle exec rake assets:precompile. Then I committed this with

git add -A
git commit -m "precompiled assets"
git push origin master
git push heroku master

这篇关于尝试了几个修正:Heroku / Rails 4资产预编译错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆