Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>To get this working in Rails 3 you'll have to do the following:</p> <p>First, create your 404 and 500 error pages. I put mine in <code>app/views/errors/404.html.erb</code> and <code>app/views/errors/500.html.erb</code>.</p> <p>Second, add the following to application_controller.rb:</p> <pre><code>unless Rails.application.config.consider_all_requests_local rescue_from Exception, :with =&gt; :render_error rescue_from ActiveRecord::RecordNotFound, :with =&gt; :render_not_found rescue_from AbstractController::ActionNotFound, :with =&gt; :render_not_found rescue_from ActionController::RoutingError, :with =&gt; :render_not_found rescue_from ActionController::UnknownController, :with =&gt; :render_not_found rescue_from ActionController::UnknownAction, :with =&gt; :render_not_found end def render_error exception Rails.logger.error(exception) render :template =&gt; "/errors/500.haml", :status =&gt; 500 end def render_not_found exception Rails.logger.error(exception) render :template =&gt; "/errors/404.haml", :status =&gt; 404 end </code></pre> <p>Finally, make your production.rb not consider all requests local:</p> <pre><code>config.consider_all_requests_local = false </code></pre> <p>P.S: Keep in mind that when a complete routing error happens - i.e when there is absolutely no route match, not just an ActiveRecord NotFound error, the public/404.html will get displayed, so it's good to have that in place. I usually just re-direct it to my errors_controller, which ensures that any 404 errors not caught by the latter mentioned exceptions are still properly redirected to ErrorsController.</p> <pre><code>&lt;script type="text/javascript"&gt; &lt;!-- window.location = "&lt;%= request.host_with_port %&gt;/errors/404" //--&gt; &lt;/script&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    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.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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