Ruby documentation seems a bit unclear on a few things such as the usage of the asset_path
and other such helper in stylesheets. Anyways this is what I did to get around the exact same problem:
-
I decided to do this the SASS-way by changing my stylesheet extensions from css to scss.
-
The image references in my code were changed from
background-image: url(<%= asset_path 'blah.png' %>);
to
background-image: image-url("blah.png");
I found the necessary documentation on the sass helpers on one of the
RailsGuides
I've also added the config.assets.digest = true
line to my config/appliction.rb
file because that seemed to get my output HTML to refer to the hashed filenames. Without the digest
flag set to true I get all of my link tags starting off with
<link href="/assets/print.css?body=1" ...
or
<href="/assets/favicon.png"...
which pretty much defies the purpose of using the assets pipeline. Especially the favicon file will still be cached by the servers and CDN's along the way.
Explicitely setting the digest flag to true gets me
<link href="/assets/print-e47f5a48af04ce6854c840d74cd28fba.css?body=1"
and
<link href="/assets/favicon-15fb5e00d868940bc32db7996e10f594.png" ...
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…