Search code examples
ruby-on-rails-3.1ruby-on-rails-3.2asset-pipelinesassrefinerycms

image_url missing assets prefix


In the scss of RefineryCMS gem, they are targeting an image for background like this:

body {
  min-height: 100%;
  margin: 0;
  padding: 0;
  font-size: 10px;
  font-family: Verdana;
  line-height: 1.5em;
  background: #303030 image_url('refinery/page_bg.png') repeat;
}

And when is compiled, it will be like this:

background: #303030 image_url('refinery/page_bg.png') repeat;

But, page_bg.png is in the assets folder: assets/refinery/page_bg.png

If I try www.mydomain.com/assets/refinery/page_bg.png I can see the image So, image_url('refinery/page_bg.png') in the compiled scss is missing the prefix assets/

How can I fix this?

I tried to create a folder in public folder named refinery and put page_bg.png inside it, but, I didn't work, and www.mydomain.com/refinery/page_bg.png won't show the image .

Is there a solution for this? any one can help? fixing the assets prefix is of course better, but, I don't mind using the public folder directly ..


Solution

  • The asset-pipeline config defines some directories as asset directories . This means the reference to the content in asset directories is without assets in front. For example , in most default configs the asset directories are : app/assets , lib/assets and vendor/assets . You can place your .png background image in each of their subfolders with the name image and refer to it just like this : background: url(your_image.png) .

    EDIT : According to this discussion, if deploying to Hiroku , there should be sass-rails included in the process of assets precompilation .