sass-rails 助手“image-url",“asset-url";无法在 Rails 3.2.1 中工作 [英] sass-rails helpers "image-url", "asset-url" are not working in rails 3.2.1
问题描述
我在 3.2.1,使用 sass-rails-3.2.4 和 sass-3.1.15...
I am on 3.2.1, with sass-rails-3.2.4 and sass-3.1.15...
资产管道的文档说:
asset-url("rails.png", image) becomes url(/assets/rails.png)
image-url("rails.png") becomes url(/assets/rails.png)
...
所以我制作了以下文件:
So I made the following file:
# app/assets/stylesheets/public/omg.css.sass
body
background: asset-url('snake.gif', image)
#lol
background: image-url('snake.gif')
当我访问 localhost:3000/assets/public/omg.css 时,我得到:
and when I visit localhost:3000/assets/public/omg.css I get:
body {
background: asset-url("snake.gif", image); }
#lol {
background: image-url("snake.gif"); }
...我也尝试将文件更改为 omg.css.scss 并将语法更改为:
... I also tried changing the file to omg.css.scss and changed the syntax to:
# app/assets/stylesheets/public/omg.css.scss
body {
background: asset-url('snake.gif', image);
}
#lol {
background: image-url('snake.gif');
}
但得到相同的结果...有没有人知道为什么这些助手不起作用?
but get the same results... does anyone have any idea why these helpers are not working?
推荐答案
尽管文档说明了这一点,但 rails 3.2.6 中的默认选项似乎允许您使用 CSS 中更少的路径信息来处理问题.例如.../app/assets/images/rails.png
是您的 example.css.scss 文件中的引用,例如:
Despite what the documentation says, it seems the default options in rails 3.2.6 allow you to just make things work with even less path information in your CSS.
E.g. ../app/assets/images/rails.png
is references in your example.css.scss file with something like:
背景:白色 url(rails.png) repeat-y;
您没有将 image-url
或 asset-url
包含到您的 scss 中(据我所知),只是简单的 url(your_image.png)
.那一点文档似乎只是对它在后台执行的操作的解释.
You don't include the image-url
or asset-url
into your scss (as far as I know), just plain url(your_image.png)
. That bit of documentation appears to be just an explanation of what it is doing in the background.
这篇关于sass-rails 助手“image-url",“asset-url";无法在 Rails 3.2.1 中工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!