To my understanding, all of your JavaScript gets merged into 1 file. Rails does this by default when it adds //= require_tree .
to the bottom of your appl
I see that you've answered your own question, but here's another option:
Basically, you're making the assumption that
//= require_tree .
is required. It's not. Feel free to remove it. In my current application, the first I'm doing with 3.1.x honestly, I've made three different top level JS files. My application.js
file only has
//= require jquery
//= require jquery_ujs
//= require_directory .
//= require_directory ./api
//= require_directory ./admin
This way, I can create subdirectories, with their own top level JS files, that only include what I need.
The keys are:
require_tree
- Rails lets you change the assumptions it makesapplication.js
- any file in the assets/javascript
subdirectory can include pre-processor directives with //=
Hope that helps and adds some details to ClosureCowboy's answer.
Sujal