Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><strong>Updated</strong></p> <p>Thought about it a little. If you only have a few types of errors, how about doing it like this?</p> <p>In your <code>routes.rb</code>, at the very <strong>last line</strong>, add a </p> <p><code>match '/my_segment/*path', :to =&gt; 'errors#not_found'</code></p> <p>This should match any path that is not defined (which normally throws <code>ActionController::RoutingError</code>) and push it to your global error page. </p> <p>You can play with play with the segments wildcard above to get your correct path. This should NOT affect your predefined paths, like <code>mydomain.com/controller1</code>. </p> <p>Below is a more fine grained method of control.</p> <p>This will help you match any errors from <code>mydomain.com/some_controller/bad_params</code></p> <pre><code>def firstController &lt; ApplicationController def method_in_first_controller # Do something here rescue @error = # Error object here render :template=&gt;"some_error_template", :status =&gt; :not_found # In specific action end end def secondController &lt; ApplicationController rescue_from ActiveRecord::RecordNotFound, :with =&gt; :rescue_not_found # In secondController def method_in_second_controller # Do something end protected def rescue_not_found @error = # Error object here render :template =&gt; 'some_error_template', :status =&gt; :not_found end end def ApplicationController rescue_from ActiveRecord::RecordNotFound, :with =&gt; :rescue_not_found # Globally protected def rescue_not_found @error = # Error object here render :template =&gt; 'application/not_found', :status =&gt; :not_found end end </code></pre> <p>Using referrer doesn't seem to get anywhere, sorry for the bad answer yesterday.</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.
    1. This table or related slice is empty.
    1. VO
      singulars
      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