zuba
zuba

Reputation: 1508

Rails 4 image-url scss helper returns wrong image path

I got in scss files few styles with background images:

> grep -r image-url app
app/assets/stylesheets/controls/player.css.scss:  background-image: image-url('armchair.jpg');
app/assets/stylesheets/controls/cards.css.scss:  background-image: image-url('cards.gif');
app/assets/stylesheets/play_section.css.scss:  background: image-url('table-grey.png') no-repeat center;

They render such css attributes respectively:

/assets/armchair.jpg
/images/cards.gif  <-- that one is wrong, it obviously returns 404
/assets/table-grey.png

What is wrong? I've searched the whole project for cards.gif and found the only line:

> grep -r cards.gif app lib
app/assets/stylesheets/controls/cards.css.scss:  background-image: image-url('cards.gif');

Upvotes: 1

Views: 356

Answers (1)

Leo Correa
Leo Correa

Reputation: 19789

Rails will use /assets/yourimage.ext with the asset path helpers. If the image is not found in your assets folder, it will fall back to using /images/yourimage.ext.

Do you have this image in your assets folder? If not try adding it and under app/assets/images/cards.gif and check if it works.

Also make sure that you clear your tmp/cache folder by using rake tmp:cache:clear

Upvotes: 2

Related Questions