In the Rails Asset Pipeline guide, they give an example of coding assets in your stylesheets by preprocessing the stylesheets with ERB. You can use the same technique with JavaScript, assuming you tack an .erb
to the end of the filename:
var someAssetPath = "<%= asset_path('some_image.png') %>";