Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Missing template error in Rails 4 when requesting format */*;

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.

like image 604
ben Avatar asked Nov 09 '22 14:11

ben


1 Answers

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.

like image 122
ben Avatar answered Nov 15 '22 04:11

ben