In my rails app, I deleted the generic file favicon.ico and replaced it with the favicon specific to the app I'm working on, which has the name 1.ico. In the head section of my application layout file, I inserted the following code:
<link rel="shortcut icon" href="/1.ico" type="image/ico" />
When I open my application in my local environment, the favicon isn't visible, and I get the following response in my terminal:
Started GET "/public/favicon.ico" for 127.0.0.1 at 2012-07-16 13:33:22 -0400
ActionController::RoutingError (No route matches [GET] "/public/favicon.ico"):
I'm not sure how I can fix this error, so any help would be great! I realize that there are a fair number of questions related to favicons, but after doing research I didn't find any questions or answers that were of help. Thanks!
Try deleting the slash sign before 1.ico.
<link rel="shortcut icon" href="1.ico" type="image/ico" />
EDIT
Try using the Favicon Rails helper:
<%= favicon_link_tag '1.ico' %>
the path you pass to favicon_link_tag is probably incorrect. if your favicon is in the public directory, you want to pass '/path/from/public/favicon.ico', but if it's in the assets directory, you want to pass 'path/from/assets/favicon.ico'. note that there's no slash in the beginning
Related
I need to generate this exact (href-lang) link HAML:
<link rel="alternate" hreflang="es" href="http://es.example.com/" />
This HAML code:
%link{href: "http://es.example.com/", hreflang: "es", rel: "alternate"}
gets converted to:
<link href="http://es.example.com/" hreflang="es" rel="alternate"></link>
Any ideas anyone?
Can you post what version of HAML you are running? Also make sure that your list of auto closed tags has not been altered.
I would also double check that your link tags are not just HTML5 "assumed closed" w/ no trailing / at the end of the tag.
https://github.com/haml/haml/blob/master/REFERENCE.md#empty-void-tags-
So I created a 16x16 favicon.ico file and placed it in my public/assets area. I also double downed and put it in my app/assets/image section.
I added and the image will not load up in Chrome, but it seems to load up in Firefox and Safari for me. That said, it won't load up in any of my friend's browsers. I also tried with or without the /.
<%= favicon_link_tag '/favicon.ico' %>
So I tried
<link rel="shortcut icon" href="cameronswiggett.com/favicon.ico" />
and same results.
I went to config/enviroments/production and made
config.serve_static_assets = true
the thing that confuses is me when I go to www.mysite.com/favicon.ico I see a broken image. So, obviously something is wrong but I am at a loss. Any suggestions?
Thanks!
Here is how I did it on my apps :
<link rel="shortcut icon" href="/img/favicon.png" type="image/png">
<link rel="icon" href="/img/favicon.png" type="image/png">
Here my favicon is in /public/img folder, it works for me so it may works for you, I added the two tags to make sure it works everywhere
I have tried to use
<link href="/favicon.ico" rel="shortcut icon" />
as well as this
<link href="/assets/favicon.ico" rel="shortcut icon" />
but I am still seeing this error in the log file
ActionController::RoutingError (No route matches [GET] "/favicon.ico"):
the favicon.ico is there in public folder (I have also put it in app/assets folder too)
How to fix this error ?
You're getting this error because you don't have a favicon.ico in your public/ directory of your application. Because the file doesn't exist there, Rails moves on, looking for a route to match against /favicon.ico in the config/routes.rb.
You can fix this in one of two ways
Manually place the favicon.ico file in the public/ directory of your application.
Put the favicon.ico in app/assets/images/ and then change your <link ... tag to use image_path
<link href="<%= image_path("favicon.ico") %>" rel="shortcut icon" />
This will place the favicon.ico in public/assets/favicon.ico, not in the document root.
I suggest sticking with #1 above.
As for why this request is even showing up in your logs, many modern browsers look in the root of the domain for /favicon.ico to use for bookmarking, or presentation in a tab or the address bar. This is why it's a good idea to keep the favicon.ico in the root of your domain, in case a browser decides (for whatever reason) to ignore your <link rel="icon shortcut" ... tag.
This is what Rails generates in application.html.erb by default:
<%= favicon_link_tag 'favicon.ico', :rel => 'shortcut icon' %>
It doesn't find favicon.ico this way when it's under /public
It works correctly (finds favicon.ico under /public) if you change the tag to:
<%= favicon_link_tag %>
Putting favicon.ico in my public folder wasn't working, so I combined some of the other answers to come up with this simple working method.
Copy the output of favicon_link_tag and inject image_path like so:
<link href="<%= image_path("favicon.ico") %>" rel="shortcut icon" type="image/vnd.microsoft.icon" />
Now place favicon.ico in your assets/images folder and you're set.
Put the favicon.ico in app/assets/images/ and then add
<link href="<%= image_path("favicon.ico") %>" rel="shortcut icon" />
in the layout file.
This works for me.
I'm using the RC and I've checked everything is up to date via NuGet.
In my global.asax.cs ive got:
BundleTable.Bundles.AddDefaultFileExtensionReplacements();
BundleTable.Bundles.AddDefaultIgnorePatterns();
BundleTable.Bundles.AddDefaultFileOrderings();
Bundle scripts = new Bundle("~/Scripts");
scripts.IncludeDirectory("~/Scripts", "*.js");
BundleTable.Bundles.Add(scripts);
Bundle css = new Bundle("~/Content/css");
css.IncludeDirectory("~/Content/css", "*.css", false);
BundleTable.Bundles.Add(css);
I've tried a few different configurations of this with no improvement.
Then in my layout ive got:
<link href="#BundleTable.Bundles.ResolveBundleUrl("~/Content/css")" rel="stylesheet" type="text/css" />
<script src="#BundleTable.Bundles.ResolveBundleUrl("~/Scripts")"> </script>
When the page loads its got decent looking urls:
<link href="/Content/css?v=QAsFYXHCbnaU70oGVxpgi9py9iKQrT9C4BVNdHa7xoI1" rel="stylesheet" type="text/css" />
But that url redirects to:
/Content/css/
Which returns a 404 not found error...
Anybody got any ideas?
The ~/Scripts and ~/Content/css virtual-path already exists on disk, so you need to make them some virtual-url, lets say ~/Scripts/js, and ~/Content/styles that's it, it's fine now.
Bundle scripts = new Bundle("~/Scripts/js");
scripts.IncludeDirectory("~/Scripts", "*.js");
BundleTable.Bundles.Add(scripts);
Bundle css = new Bundle("~/Content/styles");
css.IncludeDirectory("~/Content/css", "*.css", false);
BundleTable.Bundles.Add(css);
Also in MVC4 the Routing, Bundles, and Filters configuration has been moved to the
~/App_Start/(RouteConfig, BundleConfig, FilterConfig).cs
so check that you have those, if so then write your configurations there.
The bundle module logic that decides whether or not to handle a request, will not takeover requests to existing files or directories. So that's why your bundle requests don't work when they live at the same virtual path as an existing directory (or file).
My ruby interpreter is crashing on almost every page request with the following error:
Ruby interpreter (CUI) 1.9.2p180 [i386-mingw32] has stopped working
I am not using MySQL nor do I have the gem installed, as many of the posts online have suggested as a potential cause. Where I can begin troubleshooting this issue? My environment is stated as below. This is a critical issue as I cannot continue development in this environment so any ideas would be greatly appreciated. Thanks!
Windows 7 64bit
ruby 1.9.2p180 [i386-mingw32], installed with rubyinstaller
Rails 3.0.4
crashes with webrick/mongrel
Workaround:
Add (or change)
config.log_level = :warn
in config/environments/development.rb
(not my solution - found it in another thread)
Ok, i found the issue. My css links somehow caused the windows ruby interpreter to crash if the media attribute isn't defined on more than 1 link (crazy!).
Original (crashes):
link rel="stylesheet" href="/stylesheets/jqModal.css" type="text/css"
link rel="stylesheet" href="/stylesheets/main.css" type="text/css"
Modified (doesn't crash):
link rel="stylesheet" href="/stylesheets/jqModal.css" type="text/css" media="screen, projection"
link rel="stylesheet" href="/stylesheets/main.css" type="text/css" media="screen, projection"
Here's some insight into the same (or similar) issue.
Seems to be windows specific (again!) according to the post.
It also happens when you want to link to missing files, before you actually create them.
Then the interpreter crashes after 2 requests in my case, but if you remove the missing file links
it works just fine.
I had the same problem on windows, ruby interpreter crashing after every couple of pageloads.
my problem was here
<img src="<%= #game.image_url %>" />
and I fixed it with
<% if #game.image_url && #game.image_url != "" %>
<img src="<%= #game.image_url %>" />
<% end %>
I had this error after precompiling files for heroku. After I deleted them from public/assets folder everything worked fine.