我能够在rails应用程序的公共/资产目录中预编译资产。 但是当我在生产中启动应用程序时,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"%>和铁路试图使用以下路径获取资产,
并且文件夹中的编译资产看起来如下。
请帮我找出错误的地方。 在此先感谢,任何帮助表示赞赏。
I am able to precompile assets in public/assets directory of rails application. But when I start application in production, rails constructing wrong path and not pointing to the precompiled assets.
System environment details are as below.
rails -v Rails 5.0.4 ruby -v ruby 2.3.3p222 (2016-11-21 revision 56859) [i386-mingw32] "sprockets-rails", '2.3.3'and 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 = falseand 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)And my index.html.erb looks this way
<%=javascript_include_tag "bootstrap.min"%> <%=stylesheet_link_tag "bootstrap.min"%>and the rails trying to fetch assets using below paths,
and the compiled assets in folders looks as bellow.
Kindly help me to find out where I am going wrong. Thanks in advance and any help appreciated.
最满意答案
确保启用了摘要设置:
config.assets.digest = trueMake sure the digest setting is enabled:
config.assets.digest = true更多推荐
发布评论