This is a strange one. I started a new Rails 4 application today and then created a resource called transfer_functions. When I hit a url like localhost:3000/transfer_functions/1 it appends /favicon.ico to the end of it and I get this error in the server console.
ActionController::RoutingError (No route matches [GET] "/transfer_functions/1/favicon.ico"):
Any ideas? Thanks!
The app is using 'turbolinks' gem.
I'm using Twitter Bootstrap and created the application layout with the respective generator. I removed this line from my application.html.haml file and it fixed the problem.
%link(href="favicon.ico" rel="shortcut icon")
Not sure that I understand why that caused a problem.
The reason that error popped up was because the line you removed is essentially saying "look for a favicon.ico in the current directory". That haml code you posted renders into html that looks something like <link href="favicon.ico..."
.
The way you should handle a favicon is like this:
Put your favicon file in this directory: your_webapp/app/assets/images/
Edit your_webapp/app/views/layouts/application.html.haml
and add the following under the document's head: = favicon_link_tag
Rails will use the asset pipeline to serve the favicon just like any other site asset. You just need the file name, and don't need to include the images folder within the url.
If you're interested in the docs: http://api.rubyonrails.org/classes/ActionView/Helpers/AssetTagHelper.html#method-i-favicon_link_tag
You can also add in whatever you need to rel
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With