Heroku资产文件始终为空

Pat*_*kEm 5 heroku ruby-on-rails-4

首先,我做了很多谷歌搜索,甚至让事情在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
Run Code Online (Sandbox Code Playgroud)

为了验证,它在本地很好:

$ 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
Run Code Online (Sandbox Code Playgroud)

我的清单:

  • 我有config.serve_static_assets = true我的production.rb文件.
  • 我有gem 'rails_12factor', group: :production我的Gemfile
  • 我这样做了:heroku labs:enable user-env-compile --app=YOUR_APP.在我运行之前,资产:尽管步骤1和2,预编译也不会运行.它总是尝试初始化生产数据库.

几乎我所有的谷歌搜索都告诉我上面做了这些事情,但在这里我仍然有一个空的applicaiton.css文件.任何帮助都会很棒.

谢谢!

Pat*_*kEm 6

我找到了自己对这个问题的答案.

有问题的应用程序是我从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
Run Code Online (Sandbox Code Playgroud)

此配置行在新的rails 4应用程序中被注释掉.而Heroku文档推荐这个:

config.action_dispatch.x_sendfile_header = nil # For Heroku
Run Code Online (Sandbox Code Playgroud)

当我改变这一点时,一切都按预期工作.当应用程序在rails 3中的Cedar上运行时,这似乎并不重要.