0

缶に書いてある通り。それらのすべてではなく、javascript_include_tag :all含まれているようです。/assets/all.js

そこにすべてとすべてのサブフォルダーを含める方法はありますか?

4

1 に答える 1

3

デフォルトで生成されたものをそのまま使用しないのはなぜapplication.jsですか?

/app/assets/javascripts/application.js

// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// the compiled file.
//
// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
// GO AFTER THE REQUIRES BELOW.
//
//= require jquery
//= require jquery_ujs
//= require_tree .

最後の行に注意して//= require_tree .ください。これには、すべての JavaScript が含まれている必要があります。

/app/view/layouts/application.html.erb

<%= javascript_include_tag "application" %>

http://guides.rubyonrails.org/asset_pipeline.html#manifest-files-and-directives

require_tree ディレクティブは、指定されたディレクトリ内のすべての JavaScript ファイルを再帰的に出力に含めるように Sprockets に指示します。これらのパスは、マニフェスト ファイルに対して相対的に指定する必要があります。指定したディレクトリにのみすべての JavaScript ファイルを再帰なしで含める require_directory ディレクティブを使用することもできます。

于 2013-06-13T23:15:50.740 に答える