<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>
<channel>
	<title>Comments on: Handling Rails 404 and 500 errors</title>
	<atom:link href="http://brian.pontarelli.com/2007/01/14/handling-rails-404-and-500-errors/feed/" rel="self" type="application/rss+xml" />
	<link>http://brian.pontarelli.com/2007/01/14/handling-rails-404-and-500-errors/</link>
	<description>Brian Pontarelli</description>
	<pubDate>Thu, 20 Nov 2008 10:16:09 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6</generator>
		<item>
		<title>By: Matt</title>
		<link>http://brian.pontarelli.com/2007/01/14/handling-rails-404-and-500-errors/#comment-3531</link>
		<dc:creator>Matt</dc:creator>
		<pubDate>Mon, 16 Apr 2007 21:21:40 +0000</pubDate>
		<guid isPermaLink="false">http://brian.pontarelli.com/2007/01/14/handling-rails-404-and-500-errors/#comment-3531</guid>
		<description>You could also do the following at the end of your routes.rb file.

map.connect "*anything", :controller =&#62; "your_controller", :action =&#62; "your_action"

This will catch all badly formed requests and send them to the designated controller and view. If you want to see what was passed, you can access them via params[:anything].  You may also need a separate layout for your controller depending on what you're doing.  This will behave the same regardless of environment.

I found this out coincidently by reading the routes section in AWD w/Rails 2ed. pg. 399 and then looking at the rails rdoc for ActionController::Routing, Route globbing.</description>
		<content:encoded><![CDATA[<p>You could also do the following at the end of your routes.rb file.</p>
<p>map.connect &#8220;*anything&#8221;, :controller =&gt; &#8220;your_controller&#8221;, :action =&gt; &#8220;your_action&#8221;</p>
<p>This will catch all badly formed requests and send them to the designated controller and view. If you want to see what was passed, you can access them via params[:anything].  You may also need a separate layout for your controller depending on what you&#8217;re doing.  This will behave the same regardless of environment.</p>
<p>I found this out coincidently by reading the routes section in AWD w/Rails 2ed. pg. 399 and then looking at the rails rdoc for ActionController::Routing, Route globbing.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ben</title>
		<link>http://brian.pontarelli.com/2007/01/14/handling-rails-404-and-500-errors/#comment-3487</link>
		<dc:creator>Ben</dc:creator>
		<pubDate>Wed, 11 Apr 2007 16:03:46 +0000</pubDate>
		<guid isPermaLink="false">http://brian.pontarelli.com/2007/01/14/handling-rails-404-and-500-errors/#comment-3487</guid>
		<description>There is a better way to "tell rails to stop sucking" without changing local_request? or the consider_all_request_local.

In addition to the rescue_action_in_public method there are 2 other rescue methods defined ... rescue_action &#38; rescue_action_locally.  The easier approach is to define:

def rescue_action_locally(exception)
  rescue_action_in_public(exception)
end

so that your local and public exceptions fail the same way plus you only have to change that one call if you decide to go back to the other way where you get more diagnostic info on a local exception.

Thanks for your post it got me looking in the right direction and now I am trapping my errors</description>
		<content:encoded><![CDATA[<p>There is a better way to &#8220;tell rails to stop sucking&#8221; without changing local_request? or the consider_all_request_local.</p>
<p>In addition to the rescue_action_in_public method there are 2 other rescue methods defined &#8230; rescue_action &amp; rescue_action_locally.  The easier approach is to define:</p>
<p>def rescue_action_locally(exception)<br />
  rescue_action_in_public(exception)<br />
end</p>
<p>so that your local and public exceptions fail the same way plus you only have to change that one call if you decide to go back to the other way where you get more diagnostic info on a local exception.</p>
<p>Thanks for your post it got me looking in the right direction and now I am trapping my errors</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brian Pontarelli</title>
		<link>http://brian.pontarelli.com/2007/01/14/handling-rails-404-and-500-errors/#comment-3081</link>
		<dc:creator>Brian Pontarelli</dc:creator>
		<pubDate>Fri, 02 Feb 2007 17:00:43 +0000</pubDate>
		<guid isPermaLink="false">http://brian.pontarelli.com/2007/01/14/handling-rails-404-and-500-errors/#comment-3081</guid>
		<description>The problem still remains that if you don't have a controller or view for the URL, then Rails freaks out. So, you need to conenct the catch everything URL just in case. I have a lot of requests, mostly folks doing bad links in Word Documents and Excel spreadsheets, that come in for crap like:

/Document+C:\docs\blah/Open.aspx?foo=bar

So, I wanted to handle these since I don't have a controller or view directory named Document. In order to pull this off you need a route that handles everything that doesn't exist. This was the tough part to figure out.

Plus, the fact that Rails tries to be smart about localhost and remote hosts seems to be really lame. I want development to behave just like production, or at least as close as possible, so I can debug things properly. Not a big fan of getting things into production and crap happens that I didn't expect. Just personal preference I guess.</description>
		<content:encoded><![CDATA[<p>The problem still remains that if you don&#8217;t have a controller or view for the URL, then Rails freaks out. So, you need to conenct the catch everything URL just in case. I have a lot of requests, mostly folks doing bad links in Word Documents and Excel spreadsheets, that come in for crap like:</p>
<p>/Document+C:\docs\blah/Open.aspx?foo=bar</p>
<p>So, I wanted to handle these since I don&#8217;t have a controller or view directory named Document. In order to pull this off you need a route that handles everything that doesn&#8217;t exist. This was the tough part to figure out.</p>
<p>Plus, the fact that Rails tries to be smart about localhost and remote hosts seems to be really lame. I want development to behave just like production, or at least as close as possible, so I can debug things properly. Not a big fan of getting things into production and crap happens that I didn&#8217;t expect. Just personal preference I guess.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Doug Barth</title>
		<link>http://brian.pontarelli.com/2007/01/14/handling-rails-404-and-500-errors/#comment-3078</link>
		<dc:creator>Doug Barth</dc:creator>
		<pubDate>Fri, 02 Feb 2007 15:13:37 +0000</pubDate>
		<guid isPermaLink="false">http://brian.pontarelli.com/2007/01/14/handling-rails-404-and-500-errors/#comment-3078</guid>
		<description>In Rails 1.1, the public/404.html page is rendered on a 404 error. In Rails 1.2, public/500.html is rendered on 500 errors. If you need to render dynamic content, you will need to override the rescue_action_in_public method to point it towards your templates.

The local request check is there so that developers can receive debug information in a production environment by logging onto the prod box and hitting it directly. This distinction is only used when your app is started up in production mode. In development, all requests are considered local.

I've found that the easiest way to test error pages is to fire up your application in production mode and it it from another computer. If you don't have another computer handy, overriding the local_request? method to always return false will allow you to see what external users do.</description>
		<content:encoded><![CDATA[<p>In Rails 1.1, the public/404.html page is rendered on a 404 error. In Rails 1.2, public/500.html is rendered on 500 errors. If you need to render dynamic content, you will need to override the rescue_action_in_public method to point it towards your templates.</p>
<p>The local request check is there so that developers can receive debug information in a production environment by logging onto the prod box and hitting it directly. This distinction is only used when your app is started up in production mode. In development, all requests are considered local.</p>
<p>I&#8217;ve found that the easiest way to test error pages is to fire up your application in production mode and it it from another computer. If you don&#8217;t have another computer handy, overriding the local_request? method to always return false will allow you to see what external users do.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Henrik N</title>
		<link>http://brian.pontarelli.com/2007/01/14/handling-rails-404-and-500-errors/#comment-3068</link>
		<dc:creator>Henrik N</dc:creator>
		<pubDate>Thu, 01 Feb 2007 09:10:53 +0000</pubDate>
		<guid isPermaLink="false">http://brian.pontarelli.com/2007/01/14/handling-rails-404-and-500-errors/#comment-3068</guid>
		<description>Seems you categorized this post incorrectly ("Java", should be "Ruby/Rails").</description>
		<content:encoded><![CDATA[<p>Seems you categorized this post incorrectly (&#8221;Java&#8221;, should be &#8220;Ruby/Rails&#8221;).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brian Pontarelli</title>
		<link>http://brian.pontarelli.com/2007/01/14/handling-rails-404-and-500-errors/#comment-3034</link>
		<dc:creator>Brian Pontarelli</dc:creator>
		<pubDate>Wed, 17 Jan 2007 22:24:31 +0000</pubDate>
		<guid isPermaLink="false">http://brian.pontarelli.com/2007/01/14/handling-rails-404-and-500-errors/#comment-3034</guid>
		<description>I've looked at lighthttpd and mongrel, but I haven't messed with it. FastCGI is okay for my needs and it is pretty simple to configure, so I haven't done that fully yet. There are a few things about it that suck, but for the most part it works fine. I don't like how it has to reload the entire rails app if it hasn't been hit in a while. That causes pauses sometimes. 

However, from what I've seen with SSL, lighthttpd and mongrel can be a bit of a configuration headache, but I could be wrong. 

In terms of tuning, it is mostly in the application code and then tuning the apache/fcgi connectors (timeouts mostly). Usually I haven't had to tune much and things work fine.

What kind of tuning have you been doing?</description>
		<content:encoded><![CDATA[<p>I&#8217;ve looked at lighthttpd and mongrel, but I haven&#8217;t messed with it. FastCGI is okay for my needs and it is pretty simple to configure, so I haven&#8217;t done that fully yet. There are a few things about it that suck, but for the most part it works fine. I don&#8217;t like how it has to reload the entire rails app if it hasn&#8217;t been hit in a while. That causes pauses sometimes. </p>
<p>However, from what I&#8217;ve seen with SSL, lighthttpd and mongrel can be a bit of a configuration headache, but I could be wrong. </p>
<p>In terms of tuning, it is mostly in the application code and then tuning the apache/fcgi connectors (timeouts mostly). Usually I haven&#8217;t had to tune much and things work fine.</p>
<p>What kind of tuning have you been doing?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jeff judge</title>
		<link>http://brian.pontarelli.com/2007/01/14/handling-rails-404-and-500-errors/#comment-2987</link>
		<dc:creator>jeff judge</dc:creator>
		<pubDate>Tue, 16 Jan 2007 05:28:49 +0000</pubDate>
		<guid isPermaLink="false">http://brian.pontarelli.com/2007/01/14/handling-rails-404-and-500-errors/#comment-2987</guid>
		<description>yo!  have you had much experience with product deployments yet and stuff like lighthttpd or mongrel?  just curious.  i've deployed with apache/fastcgi...wanted to see your thoughts on tuning production servers.</description>
		<content:encoded><![CDATA[<p>yo!  have you had much experience with product deployments yet and stuff like lighthttpd or mongrel?  just curious.  i&#8217;ve deployed with apache/fastcgi&#8230;wanted to see your thoughts on tuning production servers.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
