In ajax heavy applications having a javascript/coffeescript file that is aware of the routes in a rails application seems common and reasonable. Yet it is not easy access the url_for helper in your assets.
I commonly see people inline a variable in their views that the javascript reads. And there are a few plugins that make routes available via a javascript object. See Accessing rails routes in javascript.
Am I missing an easy way to do this? Is this a bad practice? What is the alternative?
Because the standard way of using the pipeline is to compile the JS files to one file with a fingerpint, I don’t think there is an alternative to doing this.
The URL helpers often require some sort of context in the form of variables or params. For example:
question_path(@current_question)
These are not going to be available when the JS files are compiled for production.
Passing in a generated path via a content block seems OK to me (I do it in a current app).