lundi 21 septembre 2015

RoR: passing image filename to javascript

I am developing a RoR website (rails 4.2). I am new to using rails.

I have a javascript object that takes the name of an image file as a property:

var obj = new objects.Factory.MyObject({
    title: 'Sir',
    education: 'Phd',
    icon: './profile.png'
  });

I have placed my images in app/assets/images, however when I load the page, I see a 404 error when trying to retrieve the image.

I tried using image_tag which obviously, did not work in Javascript. How may I correctly specify the path of an image in a javascript code section of a RoR page?

Aucun commentaire:

Enregistrer un commentaire