0

I am working with Rails 2.3.5 and I have images in public/images/ which are added into css file named as custom.css

#cssmenu ul {
  background: url(nav-bg.png) repeat-x 0px 4px;
  height: 69px;
}

How can i make this read the image which in inside public/images ? I have tried this but it did not work

#cssmenu ul {
  background: url(<%= asset_path '/images/nav-bg.png' %>) repeat-x 0px 4px;
  height: 69px;
}

also this does not work

#cssmenu ul {
      background: url(<%= asset_path 'nav-bg.png' %>) repeat-x 0px 4px;
      height: 69px;
    }
Mostafa Hussein
  • 11,063
  • 3
  • 36
  • 61

3 Answers3

0

Can you try using the image_path helper?

background: url(image_path('nav-bg.png'));

steakchaser
  • 5,198
  • 1
  • 26
  • 34
0

Both examples are correct:

#cssmenu ul {
  background: url(../images/nav-bg.png) repeat-x 0px 4px;
  height: 69px;
}

#cssmenu ul {
  background: url(/images/nav-bg.png) repeat-x 0px 4px;
  height: 69px;
}
0

For using this <%= asset_path 'nav-bg.png' %> you will have to add .erb after file.css and it should look like yourfile.css.erb

Grey
  • 676
  • 8
  • 23