To keep my Js code clean with the Rails 3 asset pipeline I remove the require tree from the main application js file, then to load only the file that correspond to the correct controller I created this helper:
Helper
def js_controller
js = []
path = controller.controller_path.split("/")
path.shift
while path.size > 0
js << (["frontend"] << path).join("/")
path.pop
end
return js.reverse
end
Layout
-js_controller.each do |js|
=javascript_include_tag js
Design by Simon Fletcher. Powered by Tumblr.
© Copyright 2010