Rails 3.1 and Image Assets

后端 未结 7 1936
深忆病人
深忆病人 2020-11-30 16:53

I have put all my images for my admin theme in the assets folder within a folder called admin. Then I link to it like normal ie.

# Ruby    
image_tag \"admin         


        
7条回答
  •  無奈伤痛
    2020-11-30 17:12

    For what it's worth, when I did this I found that no folder should be include in the path in the css file. For instance if I have app/assets/images/example.png, and I put this in my css file...

    div.example { background: url('example.png'); }
    

    ... then somehow it magically works. I figured this out by running the rake assets:precompile task, which just sucks everything out of all your load paths and dumps it in a junk drawer folder: public/assets. That's ironic, IMO...

    In any case this means you don't need to put any folder paths, everything in your assets folders will all end up living in one huge directory. How this system resolves file name conflicts is unclear, you may need to be careful about that.

    Kind of frustrating there aren't better docs out there for this big of a change.

提交回复
热议问题