Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to use rails asset pipeline image in emberjs?

I am using ember with rails. I want to get image path in rails asset pipeline. Does emberjs has any function like asset-path in sass-rails?

like image 827
xnjiang Avatar asked Sep 28 '12 02:09

xnjiang


People also ask

How does Rails asset pipeline work?

The asset pipeline provides a framework to concatenate and minify or compress JavaScript and CSS assets. It also adds the ability to write these assets in other languages and pre-processors such as CoffeeScript, Sass, and ERB.

How do you Precompile an asset?

To compile your assets locally, run the assets:precompile task locally on your app. Make sure to use the production environment so that the production version of your assets are generated. A public/assets directory will be created. Inside this directory you'll find a manifest.


1 Answers

This is hardly ideal, but for lack of a better solution I've been handling this in my css:

.logo{
   background-image: url(image_path('logo.png'))
 }

This approach is often fine, but it has drawbacks. There's an excellent Stackoverflow discussion of using img tags vs background-image here.

like image 84
nullnullnull Avatar answered Oct 13 '22 00:10

nullnullnull