Paths to images in fixtures with Rails


I am learning ember; using ember with a rails backend and the ember-rails gem.

I am using the FixtureAdapter. In my FIXTURES, I have a imageUrl attribute.

How should the imageUrl: "/path/to/images/image.png" be referenced if I place those images in the app/assets/images/ directory?

All help is appreciated.

Thanks DJ


I figured this one out.

With the asset pipeline, one removes the /images/ directory.

Placing the image files in app/assets/image/ then, in FIXTURES , you reference imageUrl: ‘assets/image.png’


It’s all well and good in development, but what about production, when your ‘assets/image.png’ gets transformed into something like ‘assets/image-lksadf8sdfkjsdf98sd7f9s8df.png’ how would you guess what is the correct path to the image through hard coding like this?


I’ve not tried this in an Ember app but the Rails asset pipeline can run multiple pre-processors, so you could name your JS file store.js.erb, and then reference your image like so:

imageUrl: "<%= asset_path('image.png') %>"

See the ‘Coding Links to Assets’ and ‘Preprocessing’ sections of for more info.