the image(s) located in assets/images/new_design/new_img1.png
.
in new_layout.css.scss
file, have following line:
.top_bg { background-image: url("/assets/new_design/new_img1.png"); ... }
but image not rendered. i've tried also:
background-image: image-url("/assets/new_design/new_img1.png");
background-image: url("/assets/new_design/new_img1.png");
background-image: url("new_design/new_img1.png");
but none of these worked. on localhost able render third approach, don't know how on production server.
any appreciated, thank you!
images placed inside of /assets/ folder brought rails using asset pipeline. so, if want access them you'll need append .erb file can put ruby in css file that'll evaluated rails.
change new_layout.css.scss new_layout.css.scss.erb
now you've got file can run helpers, use image helper generate path image:
background-image: url(<%= asset_path 'new_design/new_img1.png' %>);
should work. utilizes asset path helper, looks through asset folder appropriate resource , created direct link.
if you're looking directly access images without pipeline, can place them in public folder of application, lose value of using asset pipeline.
as addition, production... may need precompile assets before pushing production if process doesn't include step in launch.
run following precompile assets:
rake assets:precompile
Comments
Post a Comment