Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ActionView::MissingTemplate: Missing template

I'm getting this error message when a google bot tries to visit one of my controllers.

ActionView::MissingTemplate: Missing template channels/show, application/show with {:locale=>[:"sv-SE", :en], :formats=>["*/*;q=0.9"], :handlers=>[:erb, :builder, :haml]}. Searched in: * "/opt/www/app/releases/20120228181534/app/views" * "/opt/www/app/shared/bundle/ruby/1.9.1/gems/kaminari-0.13.0/app/views"

The problem is that I can't reproduce it. The error has occurred 121 times the last week (according to airbrake).

Here is the backtrace.

Row 18, which is the only row mentioned that exists in my app, is the super part of this code

def render(options = {}, extra_options = {}, &block)
  if request.headers['X-PJAX'] or params[:no_layout] == "true" or params[:_pjax] 
    options[:layout] = false
  end
  super(options, extra_options, &block)
end

The controller method channels#show looks like this

def show
  @channel   = # ...
  @today     = # ...
  @yesterday = # ...
  @tomorrow  = # ...
end

Visiting the url that raised the error for the google bot doesn't raise an error for me.

The only urls that fails is the one that contains special char like {"action"=>"show", "id"=>"25-jönköping", "controller"=>"channels"}. The ORIGINAL_FULLPATH value is set to /channels/25-j%c3%b6nk%c3%b6ping.

I'm using rails 3.2.1.

like image 546
Linus Oleander Avatar asked Mar 05 '12 02:03

Linus Oleander


2 Answers

This has been recently fixed in master and back-ported to 3.2 branch: See https://github.com/rails/rails/issues/736 for the original bug report, https://gist.github.com/1754727 for monkey patches and github.com/rails/rails/pull/4918 for accepted pull request.

like image 137
Zbyszek Avatar answered Nov 08 '22 02:11

Zbyszek


I have seen this error as well on a Rails 3 app and have been in same boat about replicating the error. The log has the Missing Template error, but when I manually try the request, it works fine.

I suspect that the HTTP request from Google is not setting a mime that Rails is processing correctly. The crude solution I found is to remove the view template mime, so

example/index.html.erb

is now

example/index.erb

This stops the Missing Template error, since the template will be used for all mimes.

like image 2
mguymon Avatar answered Nov 08 '22 03:11

mguymon