javascript_include_tag params [:controller]在生产中不起作用

时间:2014-08-22 15:54:53

标签: javascript ruby-on-rails asset-pipeline

我希望实现控制器特定的js文件,所以我使用了以下代码并确保从app.js中删除了require_tree。

javascript_include_tag params[:controller]

因为根据asset pipeline guide

You can also opt to include controller specific stylesheets and JavaScript files only in their respective controllers using the following:

<%= javascript_include_tag params[:controller] %> or <%= stylesheet_link_tag
params[:controller] %>

When doing this, ensure you are not using the require_tree directive, as that will result in your assets being included more than once.
生产中的

,生成的代码只是<script src="/javascripts/main_page.js"></script>而不是使用预编译的名称,如main_page_12basdabsd123a.js,导致js文件无法加载。

请问我在这里失踪的地方以及如何解决这个问题?谢谢!

0 个答案:

没有答案