Note that there are some explanatory texts on larger screens.

plurals
  1. POCustom Error Pages in Rails?
    primarykey
    data
    text
    <p>I need to implement a custom error page in my rails application that allows me to use erb. </p> <p>I've been following this tutorial (<a href="http://blog.tommilewski.net/2009/05/custom-error-pages-in-rails/" rel="nofollow noreferrer">http://blog.tommilewski.net/2009/05/custom-error-pages-in-rails/</a>) and I cannot get it to work locally (or remotely). I am running Rails 2.3.5</p> <p>Here's the gist of the approach. </p> <p>1) in the 'application_controller', I over ride the "render_optional_error_file(status_code)" method, and set the visibility to "protected", like this. </p> <pre><code>protected def render_optional_error_file(status_code) known_codes = ["404", "422", "500"] status = interpret_status(status_code) if known_codes.include?(status_code) render :template =&gt; "/errors/#{status[0,3]}.html.erb", :status =&gt; status, :layout =&gt; 'errors.html.erb' else render :template =&gt; "/errors/unknown.html.erb", :status =&gt; status, :layout =&gt; 'errors.html.erb' end end def local_request? true end </code></pre> <p>I also created a folder within views called <code>errors</code> and created the following views: <code>404.html.erb</code>, <code>422.html.erb</code>, <code>500.html.erb</code>,<code>unknown.html.erb</code> and I created a new layout "errors.html.erb"</p> <p>I can't seem to get it to work. I've been trying to trigger the 404 page by navigating to <code>http://localhost:3000/foobar</code> -- but, instead of getting the new <code>404.html.erb</code>, I seem to be getting the standard apache 500 error. This happens when I try both <code>mongrel_rails start</code> and <code>mongrel_rails start -e production</code>.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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