timpone
timpone

Reputation: 19969

favicon.ico being rendered as part of query parameter; probable route issue

In localhost / WEBrick configuration (Rails 3.1, ruby 1.9.2, one of my routes takes the favicon.ico file as a request parameter. It seems to be only on this one route and am not sure sure why it is doing this:

In my routes: routes.rb

scope '/arc' do 
  match '/item/:id' => 'items#show', :as => :item_show  # id can be either integer or text 
end

In html:

<link rel="shortcut icon" href="favicon.ico" type="image/x-icon" /> 

Started GET "/arc/item/test-306-some-item" for 127.0.0.1 at 2012-10-18 12:18:18 -0700

... why is it doing this??? only on the above route?

Started GET "/arc/item/favicon.ico" for 127.0.0.1 at 2012-10-18 12:18:22 -0700
Creating scope :page. Overwriting existing method Item.page.
  Processing by ItemsController#show as 
  Parameters: {"id"=>"favicon"}

Any ideas on why it would be doing this?

Upvotes: 2

Views: 1384

Answers (3)

Firoz Ansari
Firoz Ansari

Reputation: 2515

Try:

<link rel="icon" type="image/png" href="<%= image_path("favicon.png") %>" />

Upvotes: 0

Soundar Rathinasamy
Soundar Rathinasamy

Reputation: 6728

You need to give the full path of the favicon

Like

<link rel="shortcut icon" href="/assets/favicon.ico" type="image/x-icon" />

In order to work in all environment like development and production you can use Rails tag for this

<%= favicon_link_tag "favicon.ico" %>

Upvotes: 0

Hauleth
Hauleth

Reputation: 23566

Use absolute URI /favicon.ico and then it will work as expected.

Upvotes: 4

Related Questions