Ruby on Rails:Ran rake资源:预编译,现在local和heroku部署都不包含引导程序 [英] Ruby on Rails: Ran rake assets:precompile and now both local and heroku deployment don't include bootstrap

查看:239
本文介绍了Ruby on Rails:Ran rake资源:预编译,现在local和heroku部署都不包含引导程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在将项目部署到heroku服务器时出现问题(预编译失败)。所以我找到了这个回复, https://stackoverflow.com/a/13713753/2989437 ,并且跟进了这个建议。我在application.rb文件中添加了一行:

application.rb

  module FirstEdc 
class Application< Rails :: Application
config.assets.initialize_on_precompile = false#我添加了这一行
...
end
end

然后运行预编译命令,提交更改并成功部署到heroku。但是,现在我的bootstrap / css似乎在heroku部署和我的本地部署中都停止了运行。



我了解到我应该为我添加另一行deployment.rb文件:

deployment.rb

  FirstEdc :: Application.configure do 
...

#允许本地预编译 - 由Ian添加
config.assets.prefix ='/ dev-assets'
结束

所以我添加了这个,重新编译并重新部署了,但是没有用。



最后,我运行了rake assets:clean,试图至少让我的本地部署恢复正常,但它不起作用。
$ b

任何建议将不胜感激。我现在正在更多地阅读资产管道,但我觉得这可能是缓存问题或其他问题。我会更新,因为我知道发生了什么。



编辑。为了澄清,我尝试删除两个添加项, rake assets:clean and rake assets:clean:all,但是既不修复我的本地部署。

public / assets 它不会再尝试预编译您的资产。这是设计。



因此,您需要决定是否总是使用 rake资产预编译您的资产:precompile ,或在推送到Heroku之前删除 public / assets 中的任何文件。 方法是让Heroku在推送期间预先编译它们)


I was having issues deploying my project to a heroku server (Precompile fail). So I found this response, https://stackoverflow.com/a/13713753/2989437, and followed up on the advice. I added one line to my application.rb file:

application.rb

module FirstEdc
  class Application < Rails::Application
    config.assets.initialize_on_precompile = false # I added this line
  ...
 end
end

I then ran the precompile command, committed the changes, and managed to deploy successfully to heroku. However, now my bootstrap/css appears to have stopped functioning both on the heroku deployment, and my local deployment.

I learned that I was supposed to add another line to my deployment.rb file:

deployment.rb

FirstEdc::Application.configure do
  ...

  # Allows for local precompilling --added by Ian
  config.assets.prefix = '/dev-assets'
end

So I added this, recompiled and redeployed, but to no avail.

Finally, I ran a rake assets:clean in an attempt to at least get my local deployment back to normal, but it did not work.

Any advice would be greatly appreciated. I'm reading more into the asset pipeline now, but I feel like this could be a cache problem or something. I'll update as I figure out what's going on.

edit. Just to clarify, I've tried removing both additions, running a rake assets:clean and rake assets:clean:all, but neither fix my local deployment.

解决方案

If Heroku detects any files in public/assets it will not attempt to precompile your assets again. This is by design.

So, you need to make a decision to either always precompile your assets with rake assets:precompile, or remove any files in public/assets before pushing to Heroku.

(The recommended way is to allow Heroku to precompile them during push)

这篇关于Ruby on Rails:Ran rake资源:预编译,现在local和heroku部署都不包含引导程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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