ruby on rails - can caching information attached to image file names cause a 404 error? -


i deployed rails app successfully, however, images not displaying. 404 error that's showing in console

get http://mydomain.com/assets/myimage.png 404 (not found) 

inside application directory on server, there's 3 subdirectories

current  releases  shared 

which setup created deployment script borrowed ryan bates.

i can see images in images directory of assets folder in current

  current/app/assets/images$ ls glyphicons-halflings.png  glyphicons-halflings-white.png  qb.png 

however, in assets folder of shared directory (which i'm guessing they're being put after everything's compiled production), same images have (i'm assuming) cache information attached them, such image want isn't

myimage.png  

but rather

myimage-0bb3f134943971c95b2abdfd30f932c7.png 

i'm wondering if what's causing 404 error, (i'm assuming) code's looking myimage.png in shared/assets directory.

do know how can deal problem?

contents of /shared/assets

/shared/assets$ ls application-39c95ed7b8d86b0698b6c443563e33c7.js           fontawesome-webfont-c4adb9424c8b6a6b1b9b0d2627528c4c.woff application-39c95ed7b8d86b0698b6c443563e33c7.js.gz        fontawesome-webfont-f57557847fd1897100790d9df344ded8.ttf application-7a6376d676fb88537b9f839687ccaad3.css          glyphicons-halflings-4e5b89324f1ac987ddf6835ef51f5fe9.png application-7a6376d676fb88537b9f839687ccaad3.css.gz       glyphicons-halflings-white-2fa53df59ca25ee50f59f971c0c9175d.png application-a184171300937caf263adbc5e8582ba4.css          manifest-990c8a24196fee5e9c394078c326c763.json application-a184171300937caf263adbc5e8582ba4.css.gz       myimage-0bb3f134943971c95b2abdfd30f932c7.png fontawesome-webfont-57b442a30fcae0d4334299c521a326a2.svg  twitter fontawesome-webfont-8140ac47a16c8f7074e59f2ebe0657eb.eot 

code used display images

  1. for 1 image, create span this

and assign background image

.qb{ position: absolute; width: 50px; height: 50px; background-image: url('/assets/qb.png'); left: 75px; top: 300px;  } 

for image, have template class automatically uses twitter bootstrap create x let uses click , remove page element

<script id="blahblah_template" type="text/underscore"> <h2> story <i class='icon-remove'></i></h2>  

it's triggering 404 though image on server

failed load resource: server responded status of 404 (not found)       http://mydomain.com/assets/glyphicons-halflings.png 

you should use asset helpers provided rails automagically create right url image caching build in. here how:

.qb{ position: absolute; width: 50px; height: 50px; background-image: url( <%= asset_path 'qb.png' %> );  left: 75px; top: 300px;  } 

the above map qb.png qb-0bb3f134943971c95b2abdfd30f932c7.png & update url once caching fingerprint changes. make sure stylesheet filename has .erb @ end, stylesheet.css.erb

see the asset pipeline guide more information

[edit]

for bootstrap integration rails asset pipeline, kindly use gem bootstrap-sass. fix issues images


Comments

Popular posts from this blog

Ansible - ERROR! the field 'hosts' is required but was not set -

customize file_field button ruby on rails -

SoapUI on windows 10 - high DPI/4K scaling issue -