0

因为我不想为某些视图保留我的 js 文件,所以我在视图中使用了一个辅助函数,它将 js 文件生成到 html 头中

   def javascript(*files)
    content_for(:head) { javascript_include_tag(*files) }
   end

所以我想知道如何使用资产管道和预编译机制来实现这一点?最好的,菲尔

4

1 回答 1

0

Every JS file that is being required in the HTML head section needs to be precompiled. By default only application.js is being precompiled, but you can schedule additional files for precompilation in config/application.rb:

config.assets.precompile += ['admin.js', 'customer_page.js']

Those files can be manifests, just like application.js, if you want to group the JS-files together.

于 2013-02-23T15:46:17.233 回答