5

I've been seeing these errors for a long time but haven't found an issue:

ActionView::MissingTemplate: Missing template pages/home, application/home with {:locale=>[:en], :formats=>["*/*;"]}

The user agent is always MSIE6 (which is part of the reason I gave up earlier).

To reproduce: curl -H "Accept: */*;" -I http://localhost:5000

Any one knows how to fix?

EDIT

curl -H "Accept: */*" -I http://localhost:5000 works. It doesn't work only when the format is set as */*; (notice the semi-colon).

UPDATE

I tried modifying Mime:ALL as suggested in the comments but wasn't able to have it accept both */* and */*; at the same time. A solution I see is monkey-patching how requests are handled when no or malformed mime types are present, but I'm unsure how. This answer provides a clue but I still don't have one.

MORE UPDATE

I'm still seeing these errors and more. A new one is with :formats=>["hc/url;*/*"] (Firefox). I'm so surprised this isn't hitting anyone else, I don't think I have anything specific in my code that would lead to uncommon errors.

Community
  • 1
  • 1
ben
  • 1,432
  • 12
  • 17
  • set root in `routes.rb` as `root "pages#home"` – Rajarshi Das May 02 '15 at 07:00
  • Rails maps `"*/*" => :all` , I'm not sure how but you could probably coerce treating :all as a :html request – max May 02 '15 at 07:41
  • All my routes are correctly set Rajarshi. Actually the issue is subtle. `*/*` works, `*/*;` doesn't. – ben May 02 '15 at 07:45
  • Hmm, I'm thinking that you could fix this by registering a mime type `Mime::Type.register "*/*;", :all`. Or possibly Mime::ALL = Mime::Type.new("*/*", :all, ['*/*;']). I think you would need to do this in an initializer. https://github.com/rails/rails/blob/4f6f43338f7e4d3a3fe5ad86d024007ee95a7389/actionpack/lib/action_dispatch/http/mime_types.rb – max May 02 '15 at 16:37
  • It worked! Redefining Mime::ALL throws a warning so the register is probably best. You should put that in an answer and I'll accept it! – ben May 03 '15 at 06:17
  • Nevermind, both version throw a warning. At least it properly routes requests.. – ben May 03 '15 at 06:49
  • Update: turns out `*/*` stopped working after my update, simply because it was overriden, so very bad idea. – ben May 04 '15 at 23:36
  • http://stackoverflow.com/a/4905464/811653 I use this, it works very well. – emj365 Oct 07 '15 at 15:25

1 Answers1

1

gregkare just posted a fix on github.

DEFAULT_RESPONSE_FORMAT = :html  
before_filter :set_default_response_format

def set_default_response_format
  request.format = DEFAULT_RESPONSE_FORMAT if request.format.to_sym.nil?
end

Not exactly sure about side effects but seems to work great for now.

ben
  • 1,432
  • 12
  • 17