although that solution is technical feasible, mvc encourages us to separate concerns. This is a view concern, and as such the controller "shouldn't" be concerned.
why not use the layout for this controller?
Jodi
although that solution is technical feasible, mvc encourages us to separate concerns. This is a view concern, and as such the controller "shouldn't" be concerned.
why not use the layout for this controller?
Jodi
or you could have the application layout check the controller name, and return the JS include. This is probably a good use for a helper - < %= get_JS(controller.controller_name) %>
I'd likely tackle by that means - the application helper might even have scope to access the controller object, so your call would just be "get_JS"
I wrote a plugin a while ago just for this.
You can find details for it at
http://www.agilewebdevelopment.com/plugins/resource_on_demand
Hopefully it will do what you’re after
I usually just build up an array within my controller such as:
@javascript_includes = ['prototype','scriptaculous','other_file']
and then in my layout have:
<%=javascript_include_tag *@javascript_includes -%>
Regards,
Glenn