2014-05-13 137 views
0

我目前的问题与本帖子中描述的完全相同:Rails not serving assets in production or staging environments未在Windows上投入生产的Rails 4资产

我在Windows 7的生产环境中运行Rails 4.0.4(所以很容易成为问题,不能很好地使用Linux)。我运行了rake assets:clobber以确保所有内容都已清理完毕,然后RAILS_ENV=production rake assets:precompile,并成功完成,没有错误或警告。所有的文件出现在我的公共/资产文件夹中,并使用Windows资源管理器,我可以查看application.js和application.css中的文本,并正确显示图像。但是,当我尝试访问localhost:3001/assets/application.js时,它与application.css相同,并且图像文件出现错误。每次更改设置和预编译后,我都重新启动了服务器。

当我看着日志说它的页面呈现成功,没有像我在其他帖子中看到的“没有路由匹配”的错误。所以资产被发现,但由于某种原因,他们没有得到适当的服务。

这里是我的production.rb:

ABC::Application.configure do 

    config.cache_classes = true 
    config.eager_load = true 
    config.consider_all_requests_local  = false 
    config.action_controller.perform_caching = true 
    config.action_dispatch.x_sendfile_header = "X-Sendfile" 
    config.serve_static_assets = true 
    config.action_mailer.default_url_options = { :host => '' } 
    config.i18n.fallbacks = true 
    config.active_support.deprecation = :notify 
    config.assets.js_compressor = :uglifier 
    config.assets.css_compressor = :sass 
    config.assets.compile = false 
    config.assets.digest = true 

end 

任何帮助将不胜感激,我一直停留在这近两天!

回答

0

就在我输入完这个问题之后,我终于碰到另一篇文章,里面说头文件已被设置,但没有任何内容,这听起来像是我的问题。他们使用nginx的,并通过改变固定的问题如下:

# Specifies the header that your server uses for sending files 
# config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache 
config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx 

而且看到,因为我不使用Apache或nginx的,我注释掉了两条线,最后我的资产服务。事后看起来很明显,但我认为我会发布这个以防万一它有帮助其他人有同样的问题。