首先,我做了很多谷歌搜索,甚至让 Heroku 上的东西正常工作,但似乎无论我是让 Heroku 在 slug 编译期间预编译我的资产,还是我自己预编译它们并提交它们,无论哪种方式,我的 Rails 4 应用程序的 application.css 始终为空:
$ curl -i http://www.boxscoregeeks.com/assets/application-c712146df692b0fca6c21c0bf1dddcd5.css
HTTP/1.1 200 OK
Content-Type: text/css
Date: Sun, 01 Sep 2013 00:50:10 GMT
Last-Modified: Sun, 01 Sep 2013 00:46:54 GMT
Status: 200 OK
X-Sendfile: /app/public/assets/application-c712146df692b0fca6c21c0bf1dddcd5.css
Content-Length: 0
Connection: keep-alive
经验证,本地没问题:
$ curl -I http://localhost:3001/assets/application-c712146df692b0fca6c21c0bf1dddcd5.css
HTTP/1.1 200 OK
Last-Modified: Sat, 31 Aug 2013 03:46:55 GMT
Content-Type: text/css
Content-Length: 106237
Connection: keep-alive
Server: thin 1.5.1 codename Straight Razor
我的清单:
- I have
config.serve_static_assets = true
在我的 Production.rb 文件中。
- I have
gem 'rails_12factor', group: :production
在我的 Gemfile 中
- 我这样做了:
heroku labs:enable user-env-compile --app=YOUR_APP
。在我运行之前,尽管执行了步骤 1 和 2,assets:precompile 也不会运行。它始终会尝试初始化生产数据库。
几乎所有的谷歌搜索都告诉我要做上面的这些事情,但这里我仍然有一个空的 applicaiton.css 文件。任何帮助都会很棒。
Thanks!
我找到了自己对这个问题的答案。
该应用程序是我从 Rails 3 升级的应用程序。因此我构建并部署了一个空的新 Rails 4 应用程序(并且这有效)。通过区分production.rb
文件中,我注意到非工作应用程序中有这样一行:
# Specifies the header that your server uses for sending files
# (comment out if your front-end server doesn't support this)
config.action_dispatch.x_sendfile_header = "X-Sendfile" # Use 'X-Accel-Redirect' for nginx
此配置行在新的 Rails 4 应用程序中被注释掉。 Heroku 文档推荐这样做:
config.action_dispatch.x_sendfile_header = nil # For Heroku
当我改变这个时,一切都按预期进行。当应用程序在 Rails 3 中的 Cedar 上运行时,这似乎并不重要。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)