【发布时间】:2014-05-13 07:20:12
【问题描述】:
我目前遇到的问题与这篇文章中描述的完全相同:Rails not serving assets in production or staging environments。
我在 Windows 7 的生产环境中运行 Rails 4.0.4(这很容易成为问题,不幸的是不能使用 Linux)。我已经运行 rake assets:clobber 以确保所有内容都已清理干净,然后运行 RAILS_ENV=production rake assets:precompile 并成功运行,没有错误或警告。所有文件都出现在我的 public/assets 文件夹中,使用 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
任何帮助将不胜感激,我已经坚持了将近两天!
【问题讨论】:
标签: windows ruby-on-rails-4 asset-pipeline