Acquire Asset Path from JavaScript
问题 I need to display images on an HTML5 canvas that are in the Rails asset pipeline, but I need to know the path for the asset from JavaScript. I'm using js-routes for other parts of the application, but it doesn't appear to provide a way to get the path to something in the asset pipeline. What's the correct way to obtain the path to a Rails asset (e.g., an image) from JavaScript? 回答1: In the Rails Asset Pipeline guide, they give an example of coding assets in your stylesheets by preprocessing