Topic: exceptions thrown outside of an action

So I have a rails that is working and I add a new Model and now I get the following error:

Application error

Change this error message for exceptions thrown outside of an action (like in Dispatcher setups or broken Ruby code) in public/500.html

Re: exceptions thrown outside of an action

Check log/development.log and log/mongrel.log (if you're running Mongrel).

Re: exceptions thrown outside of an action

So, is there a way to turn off the friendly error messages? I had to run edge rails for a plugin I am using, and I don't want to have to look in the log for the errors. I have looked all over the place for an answer to this. I am admittedly fairly new to Rails, but have been programming for years.

Re: exceptions thrown outside of an action

What do you mean by friendly error messages? The error message that shows up when an exception occurs? You can override the local_request? method in ApplicationController to always return false. This should turn off the friendly error messages (maybe only in production though).

# in ApplicationController
def local_request?
  false
end

Railscasts - Free Ruby on Rails Screencasts

Re: exceptions thrown outside of an action

I actually want the detailed error messages in development. I am currently getting the 500.html (I am on Edge Rails).

I figured out that it has something to do with the fact that I am using a custom host file to use domains such as subdomain.localhost.com to test functionality that requires the subdomain. I checked the local_request? method and found that it was using the IP address and not the hostname, but it only happens on the pages w/ a subdomain other than nil or www.

I will try defining it to alway return true in development.

Thanks!

Re: exceptions thrown outside of an action

You're getting just the Application Error because that's what happens when in Production mode.

I alleviated this problem by editing my application.rb file and adding in the detailed error message in an HTML comment, like so:

application.rb

def rescue_action_in_public(exception)
    render :text => "<html><body><p>
        There was a global error processing your request.</p>
        <!--  #{exception}  --></body></html>"
end

def local_request?
    false
end