Rails 3.1 and Image Assets

后端 未结 7 1945
深忆病人
深忆病人 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:23

    You'll want to change the extension of your css file from .css.scss to .css.scss.erb and do:

    background-image:url(<%=asset_path "admin/logo.png"%>);
    

    You may need to do a "hard refresh" to see changes. CMD+SHIFT+R on OSX browsers.

    In production, make sure

    rm -rf public/assets    
    bundle exec rake assets:precompile RAILS_ENV=production
    

    happens upon deployment.

提交回复
热议问题