1

When I call image_url('path/to/image.png') in my css.scss file, I get this error:

ActionView::Template::Error (Unrecognized file type: png)
  (in /home/ramon/source/unstilted/app/assets/stylesheets/admin.css.scss)):
    ...
  app/assets/stylesheets/admin.css.scss:134
  app/views/layouts/site_admin.html.haml:8:in `_app_views_layouts_site_admin_html_haml__354054488_99259250'

I'm using compass '0.12.0.alpha.0' from the rails_31 branch. Not sure if that's the issue. But I thought it was worth mentioning.

How do I include images in a css.scss file?

Ramon Tayag
  • 15,224
  • 9
  • 43
  • 69

3 Answers3

4

actually, using background: image-url('name-of-image.png') seems to work just fine. (Note the hyphen instead of an underscore).

Chris
  • 9,994
  • 3
  • 29
  • 31
0

You need to name the file admin.css.scss.erb.

Then you can use view helpers in your css.

background-image: url(<%= image_url('foo.jpg') %>)

Not pretty, does the job.

Douglas F Shearer
  • 25,952
  • 2
  • 48
  • 48
0

Apparently, it was something that wasn't working properly in that version of compass that I was using. See this thread for details.

Ramon Tayag
  • 15,224
  • 9
  • 43
  • 69