Rails 5无法在生产模式下加载资产

时间:2017-07-10 13:27:48

标签: ruby-on-rails ruby assets

我可以在rails应用程序的 public / asset 目录中预编译资产。 但是当我在生产中启动应用程序时,rails构建了错误的路径而没有指向预编译的资产。

系统环境详情如下。

rails -v
Rails 5.0.4

ruby -v
ruby 2.3.3p222 (2016-11-21 revision 56859) [i386-mingw32]

"sprockets-rails", '2.3.3'

和production.rb

  # Disable serving static files from the `/public` folder by default since
  # Apache or NGINX already handles this.
  config.public_file_server.enabled = true

  # Do not fallback to assets pipeline if a precompiled asset is missed.
  config.assets.compile = false

和asset.rb

# Precompile additional assets.
# application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
Rails.application.config.assets.precompile += %w( *.js *.css *.js.erb *.css.erb)

我的index.html.erb看起来就是这样

<%=javascript_include_tag "bootstrap.min"%>
<%=stylesheet_link_tag "bootstrap.min"%>

并且rails试图使用以下路径获取资产,

enter image description here

并且文件夹中的编译资产看起来如下。

enter image description here

请帮我找出错误的地方。 提前致谢,感谢任何帮助。

1 个答案:

答案 0 :(得分:1)

确保已启用摘要设置:

config.assets.digest = true