application.js as shown in many screencasts with trivial apps has proven to be problematic to say the least. It’s brittle code that could very well infiltrate unintended areas of the site that happen to use the same classes or id’s. Bad juju.
This approach still chucks everything into just one or maybe a few big js files, but uses namespacing to get around the potential conflicts. As far as I can tell, though, this approach requires that the user use the next approach via a helper method.
This is old news and we use it to great effect, but it has drawbacks because it does not rely on convention over configuration. Also, if you have a few
<%= yield :foo %> areas, your actions become a muddle of template code and actual action code. Currently we’re using
content_for for a few different areas of the page, and it’s already becoming messy in the actions.
Convention over Configuration 3