inexplicable 'Application error (Rails)' in production

I'm hoping someone can point out something obvious I'm not seeing.
Heres the problem:

When in production mode, when an error occurrs I get the white screen error:

Application error (Rails),

And, I can't seem to override the method rescue_action_in_public, even
though I'm *certain* local_request? is returning false. If I try to
just render some text to the screen, inside that method in my
application controller class, I still get the 'Application error
(Rails)' error. So, I can't implement any exception handling in
public. Now, I can set

config.action_controller.consider_all_requests_local = true

and I can see the error. So, somehow the request is NOT being seen as
local, yet any attempts to catch it aren't working. Help. :slight_smile:

Thanks!

Rich

Re: [Rails] inexplicable ‘Application error (Rails)’ in production
If you are getting this error, it’s a 500 server error. Your dispatcher is never even seeing it. Look at the error-page specification to see what page is displayed in the case of a 500 — I’ll bet it’s the page you are now seeing.

Steve

Totally baffled/frustrated by this still. Any and all ideas are
welcomed :slight_smile: Even if they are obvious.

I cannot understand why I can't overwrite these methods. I can't even
overwrite rescue_action, which would allow me to handle all exceptions
regardless of being local or not. What's odder still is that I have
another rails app on the same box, running fine, without this issue.

System details:

I'm on a VPS running
Fedora Core 4
Ruby 1.8.4
Rails 1.1.6
SCGI

Totally baffled/frustrated by this still. Any and all ideas are
welcomed :slight_smile: Even if they are obvious.

I cannot understand why I can’t overwrite these methods. I can’t even
overwrite rescue_action, which would allow me to handle all exceptions

regardless of being local or not. What’s odder still is that I have
another rails app on the same box, running fine, without this issue.

Hi Rich

Another rails app on the same box …? Is it a different instance of the same app? If not then there is no comparison, if yes, then are they sharing the same session store?

I would recommend looking into

A. session store. This can happen due to stale session data, if you are running memcache restart it, if you use PStore then delete all session files and restart your application, if you use DataStore

for session then delete all rows from session table.

B. run the application in debug mode, set logger level to debug, your logs should tell you what is causing this 500 internal error.

hope this helps

-daya

Another rails app on the same box ....? Is it a different
instance of the same app? If not then there is no comparison, if yes, then
are they sharing the same session store?

no, different instances

I would recommend looking into

A. session store. This can happen due to stale session
data, if you are running memcache restart
it, if you use PStore then delete all
session files and restart your application, if you
use DataStore
for session then delete all rows from session table.

just PStore, and I tried that

B. run the application in debug mode, set logger level to debug, your logs
should tell you what is causing this 500
internal error.

That's the thing. I *know* what the errors are. I just can't catch
(handle) them in production. So while I know what the errors are, that
still doesn't help me catch them.. becasue I can't seem to overwrite
rescue_action or rescue_action_in_public. ActionController catches
them just fine, but my app can't :frowning:

minor update.. neither app can overwrite the recue_action_in_public
method. Although I am sure the first one could at one point. hmm. what
could have changed to casue this???

hi rich
i have had a similar problem and it tourned out to be a dispatch problem
i don’t know if you have other rails app that works.
for me, i reinstalled fcgi again and it worked.

Rich,

Sounds to me like your dispatch isn't even running. I'd go back to the
basics and make sure your line endings, ownership, permissions, and
shebang line are all correct.

Good luck and let us know when you figure it out!
Tim

Rich Brant wrote:

When in production mode, when an error occurrs I get the white screen error:

Application error (Rails),

And, I can't seem to override the method rescue_action_in_public, even
though I'm *certain* local_request? is returning false.

What is the error, and where are you redefining
rescue_action_in_public?

Some Rails errors sort of occur before your controller ever enters the
picture (don't ask me for details!). If you're redefining
rescue_action_in_public in your controller (or even in your
ApplicationController, I think), errors like that will trigger the
built-in rescue_action_in_public since Rails hasn't reached your
controller yet.

Maybe this is what's happening in your app? It's hard to tell without
knowing what the exception is, where it's occurring
and
where you're redefining the method.

In my apps I redefine rescue_action_in_public in a little 'support'
file in /lib that I include in environment.rb. It seems to catch pretty
much everything.

/config/environment.rb:

require 'myapp_support'

/lib/myapp_support.rb:

module ActionController
  module Rescue
    protected
    def rescue_action_in_public(exception)
      case exception
        when RoutingError, UnknownAction then
          render_text(IO.read(File.join(RAILS_ROOT, 'public',
'404.html')), "404 Not Found")
        else
          render_text(IO.read(File.join(RAILS_ROOT, 'public',
'500.html')), "500 Internal Error")
      end
    end
  end
end

(I'm pretty sure I just copy-pasted this from somewhere in the past,
but I can't remember from where that might have been.)

Chris

It turned out to be a plugin I was using, 'meantime_filter' I havent'
looked into the code enough to know exaclty why yet, but i plan
to..thanks for the help though.