Jump to content

The ultimate community for Ruby on Rails developers.


Photo

Help me understanding assets path

favicon_link_tag

  • Please log in to reply
2 replies to this topic

#1 rovf

rovf

    Passenger

  • Members
  • 4 posts

Posted 04 June 2014 - 01:34 PM

(Note: I have posted this question already a couple of days ago at https://www.ruby-for...m/topic/4937672 , but crosspost it now here too, since I haven't got any response yet).

 

 

I've put my favicon into app/assets/images and include in my header
 

<%= favicon_link_tag 'my_favicon.jpg' %>

The favicon is correctly recognized by the browser, so it works perfectly. When viewing the source code, I see to my surprise that the following HTML code is generated:
 

<link href="/assets/my_favicon.jpg" rel="shortcut icon" type="image/vnd.microsoft.icon" />

Aside from the MIME type (I had expected that rails would generate image/jpeg), what really puzzles me is the path. The file is definitely in /assets/images, not in /assets . How can the browser locate the file?



#2 Ohm

Ohm

    Driver

  • Moderators
  • 354 posts
  • LocationCopenhagen

Posted 04 June 2014 - 02:25 PM   Best Answer

The internal Rails router doesn't adhere to the folder structure when running as a server.

 

You'll also note that all your javascript- and css-files have their own folder, but the asset-paths created for them are all like /assets/stylesheet.css 


  • Jamie likes this
Blog: http://ohm.sh | Twitter: @madsohm

#3 rovf

rovf

    Passenger

  • Members
  • 4 posts

Posted 06 June 2014 - 06:35 AM

Thank you for the explanation.

 

I thought that the consolidation of the stylesheets is done by Sprockets (where I request it explitily by doing a 'require_tree' in application.css). I was not aware that something comparable would be going on implicitly for the image files too!






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users