Heroku 没有预编译我的资产来为资产管道准备我的应用程序
我在使用 Rails 3.1.1 让我的资产管道设置与 Heroku/Cedar 一起使用时遇到了一些麻烦
我已经推送了我的应用程序并且它成功启动,但没有消息说“准备资产管道”并且没有静态资产正在被送达。由于没有进行 slug 编译时间或运行时资产编译,因此找不到 JS、CSS 或图像。
任何帮助将不胜感激。
他们在此链接描述了部署期间应该发生的情况,我将在下面进行总结:
对于 Heroku Cedar 上的 Rails 3.1 应用程序,当您 git push heroku 时,您的资产将作为部署过程的一部分,使用 rake 任务包 exec rake asset:precompile 进行预编译。
I'm having a bit of trouble getting my asset pipeline setup working with Heroku/Cedar using Rails 3.1.1
I've pushed my application and it launches successfully but there was no message that said "Preparing asset pipeline" and no static assets are being served up. No JS, CSS, or images are able to be found as there is no slug compilation time or runtime asset compilation being done.
Any help would be greatly appreciated.
They describe what should happen during deployment at this link which I'll summarize below:
With a Rails 3.1 application on Heroku Cedar when you git push heroku your assets will all be pre-compiled as part of the deploy process by using the rake task bundle exec rake assets:precompile.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
好的,解决方案是这样的:
我使用 mongoid,它让您删除“rails/all”行作为配置的一部分。结果是链轮没有被加载。
对于 Rails 3.1+,您还需要在 application.rb 中添加
require "sprockets/railtie"
以便启用 sprockets。繁荣,有效。此信息可以在 mongoid 网站此处找到。对于那些可能未在 application.rb 中加载完整“rails/all”的人来说,了解这一点很有用,显然需要链轮才能使资产管道正常工作。
Ok so the solution was this:
I'm using mongoid which has you remove the 'rails/all' line as part of the configuration. As a result sprockets was not being loaded.
What you need to do with rails 3.1+ is also add
require "sprockets/railtie"
in application.rb so that sprockets are enabled. Boom, works.This info can be found on the mongoid website here. This is useful to know for anyone who may not be loading the full 'rails/all' in application.rb, sprockets is obviously required for the asset pipeline to work.
您是否看过 Heroku 上有关 Rails 3.1 资产管道的文章 - http://devcenter.heroku.com/articles/ Rails31_heroku_cedar。我昨天回顾了它并从中获得了一些提示,并且我已经在 Heroku 上运行 Rails 3.1 站点有一段时间了。
这是一个新的 Rails 3.1 站点还是升级到 Rails 3.1 的站点,需要检查的是资产管道是否已启用用于生产 - 默认情况下 Rails 3.1
在 application.rb 中使用。您是否使用应用程序/资产作为您的资产而不是公开/
Have you seen this article on Rails 3.1 asset pipeline on Heroku - http://devcenter.heroku.com/articles/rails31_heroku_cedar. I reviewed it yesterday and picked up a good few hints from it and I've been running Rails 3.1 sites on Heroku for quite a while now.
Was this a new Rails 3.1 site or a site upgraded to Rails 3.1, things to check would be that the asset pipeline is enabled for production - by default Rails 3.1 uses
in application.rb. Are you using app/assets for your assets and not public/