Step 1) Remove
require_tree . from
application.js. I have decided to reserve
application.jsfor requiring any global scripts that I may need.
Step 2) Modify
application.html.erb to include our controller/action specific .js files
Using some of the methods that come readily available with ActionView, we are able to extract the name of the controller and action we are currently on. In the included example project, when you visit the
Step 3) Add
config.assets.precompile += %w(*/*) to
config/application.rb so your assets are precompiled.
I hope this helped someone, if you have a method to improve or have valuabe input on why this wouldn't be a good solution, I would love to hear from you!
P.S. I appologize that the formatting in my post is kind of quirky. I have been meaning to update my design but haven't got around to it yet.