rails assets pipeline with yielded javascript

余生颓废 提交于 2019-12-13 04:17:32

问题


since I wan't to keep my js files separated for some views, I am making use of a helper function inside the view which yields the js file into the html head

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

So I was wondering how can I achieve this with assets the pipeline and the pre compile mechanism? Best, Phil


回答1:


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.



来源:https://stackoverflow.com/questions/15042114/rails-assets-pipeline-with-yielded-javascript

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!