开发者

Rails 3.1 assets: Calling image_url in scss raises Unrecognized file type

When I call image_url('path/to/image.png') in my c开发者_JAVA技巧ss.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?


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


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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜