0

I want to include the following code block in my application.html.erb:

<link rel="apple-touch-icon" sizes="180x180" href="images/icons/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="images/icons/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="images/icons/favicon-16x16.png">
<link rel="manifest" href="images/icons/site.webmanifest">
<link rel="shortcut icon" href="images/icons/favicon.ico">
<meta name="apple-mobile-web-app-title" content="MenuTranslator">
<meta name="application-name" content="MenuTranslator">
<meta name="msapplication-TileColor" content="#da532c">
<meta name="msapplication-config" content="images/icons/browserconfig.xml">
<meta name="theme-color" content="#ffffff">

These ten lines take care of all my icon needs. I've seen this question and frankly I don't know how to get these ten lines using that method, and frankly I'm not that interested in spending time figuring it out when this already works. Except-- it doesn't work, because I'm using the wrong path. images/icons/filename doesn't work.

How can I do this? Does rails not allow me to do this?

temporary_user_name
  • 35,956
  • 47
  • 141
  • 220

1 Answers1

1

Place that images folder inside the app/public/ directory, put a slash in front of all those paths like below (or just copy and paste that) and it will work.

<meta name="apple-mobile-web-app-title" content="MenuTranslator">
<meta name="application-name" content="MenuTranslator">
<meta name="msapplication-TileColor" content="#da532c">
<meta name="msapplication-config" content="/images/icons/browserconfig.xml">
<meta name="theme-color" content="#ffffff">
<link rel="apple-touch-icon" sizes="180x180" href="/images/icons/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="/images/icons/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="/images/icons/favicon-16x16.png">
<link rel="manifest" href="/images/icons/site.webmanifest">
<link rel="shortcut icon" href="/images/icons/favicon.ico">
Rockwell Rice
  • 3,376
  • 5
  • 33
  • 61
  • You're right, it worked, thank you-- but I don't understand why it worked. What is the difference between images placed in `app/public/images` and `app/assets/images`? And also why is `application.html.erb` apparently using `app/public` as its relative location for pathing despite not being located there? I'm not sure how I could have known that. – temporary_user_name Nov 04 '18 at 01:24
  • The images in the assets folder would use an `<%= image_tag('/images...') %>` to link to them, which could also work. – Rockwell Rice Nov 04 '18 at 03:15
  • 1
    @Aerovistae I would also read over this, https://guides.rubyonrails.org/asset_pipeline.html, it should help explain what is going on there and hopefully clear some stuff up for you. Happy coding! – Rockwell Rice Nov 04 '18 at 18:17