当我被这行代码绊倒时,我正在阅读有关 Rails 4 和 Asset Pipeline 的文档:
If you are upgrading from Rails 3, please take into account that assets under lib/assets or vendor/assets are available for inclusion via the application manifests but no longer part of the precompile array
http://edgeguides.rubyonrails.org/asset_pipeline.html#asset-organization
可通过应用程序 list 包含和作为预编译数组的一部分有什么区别?这是否意味着,如果我有一个 javascript 文件 lib/vendor/cool_plugin.js
,即使我有 //require Cool_plugin
,当我投入生产时,我也会得到 404 > 在 application.js
中?
最佳答案
来自http://edgeguides.rubyonrails.org/upgrading_ruby_on_rails.html :
In Rails 4.0, precompiling assets no longer automatically copies non-JS/CSS assets from vendor/assets and lib/assets. Rails application and engine developers should put these assets in app/assets or configure config.assets.precompile.
所以我认为您需要明确引用您的供应商 Assets ,以便在生产预编译期间获取它们:
# production.rb
config.assets.precompile += %w( cool_plugin.js )
关于ruby-on-rails - 带有 Lib 和 Vendor 文件夹的 Rails 4 Asset Pipeline,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23641676/