问题
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