Note that there are some explanatory texts on larger screens.

plurals
  1. POSuppressing ActionView::MissingTemplate exception for Rails 3.x
    text
    copied!<p>Starting with Rails 3.0, from time to time, I've been receiving an exception notification like this:</p> <pre><code>ActionView::MissingTemplate: Missing template [...] with {:locale=&gt;[:en], :formats=&gt;[:text], :handlers=&gt;[:erb, :builder, :haml]}. Searched in: * [...] </code></pre> <p>For instance, an arbitrary hand-written URL like <a href="http://example.com/some/path/robots.txt">http://example.com/some/path/robots.txt</a> raises the error. Not fun.</p> <p>I reported the problem in this ticket quite a long ago, and been using the patch mentioned here, but the problem persists.</p> <p><a href="https://rails.lighthouseapp.com/projects/8994/tickets/6022-content-negotiation-fails-for-some-headers-regression">https://rails.lighthouseapp.com/projects/8994/tickets/6022-content-negotiation-fails-for-some-headers-regression</a></p> <p>A fix is suggested in this blog post,</p> <p><a href="http://trevorturk.wordpress.com/2011/12/09/handling-actionviewmissingtemplate-exceptions/">http://trevorturk.wordpress.com/2011/12/09/handling-actionviewmissingtemplate-exceptions/</a></p> <p>To use this:</p> <pre><code>respond_to do |format| format.js end </code></pre> <p>But it doesn't feel right to me, as I'm not interested in overloading an action with multiple formats. In my app, there are separate URLs for HTML and JSON API, so simple <code>render</code> should be sufficient.</p> <p>Should I just swallow the exception by <code>rescue_from ActionView::MissingTemplate</code> and return 406 myself?</p> <p>Is there a better way to handle this situation?</p> <p>Or I can ask this way - in the first place, is there any real-world usefulness in raising this kind of exception on production?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload