Reputation: 108
In production, we regularly get the following exception:
An ActionView::MissingTemplate occurred in constructions#show:
Missing template constructions/show, application/show with {:locale=3D>[:= ru], :formats=3D>[:jpeg, "image/pjpeg", :png, :gif], :handlers=3D>[:erb, :b= uilder, :coffee, :jbuilder, :haml]}
What puzzles me here is the formats hash, which requests for some image (:jpeg, "image/pjpeg", :png, :gif). We have no custom MIME types registered in our app, and as far as I know there's no corresponding Rails default MIME-type.
So the question is: what kind of request generates this formats hash?
Upvotes: 1
Views: 1265
Reputation: 24256
I got same error as well. I notices this is from a search engine of "YandexImage" trying to get custom format. On my controller and action is just empty, because it is a static *.html.erb page. Here is more information.
* DOCUMENT_ROOT : /srv/www/apps/mysite/current/public
* HTTP_ACCEPT : image/jpeg, image/pjpeg, image/png, image/gif
* HTTP_CONNECTION : Keep-Alive
* HTTP_FROM : [email protected]
* HTTP_HOST : mysite.com
* HTTP_USER_AGENT : Mozilla/5.0 (compatible; YandexImages/3.0; +http://yandex.com/bots)
* ORIGINAL_FULLPATH : /
Two ways to fix this:
Edit public/robots.txt to block YandexImage. see more information at http://yandex.com/bots
User-agent: YandexImage
Disallow: /
Or put following code to your action, it will handle only html otherwise raise the not found page
respond_to do |format|
format.html
format.any { raise ActionController::RoutingError.new('Not Found') }
end
Upvotes: 2