[Rails] Re: default error page
Eric Anderson
eric at afaik.us
Tue Jan 11 15:39:53 GMT 2005
Raffaele Tesi wrote:
> I need redirection to a custom error page, instead of
> the default Rails messages (e.g. Unknown action).
> I use WebRick, no Apache, and i think i can't use
> public/.htaccess (# General Apache options).
You will need to ensure that the following is set in your configuration
environment:
ActionController::Base.consider_all_requests_local = false
If you are using the production environment this will already be set. If
you are using the development environment then you will need to change this.
Next you will need to figure out who should receive the custom error
message and who should receive the stack trace. Then overwrite the
"local_request?" method in your controller (or your
ApplicationController to make it affect all controllers) to determine
for your application when a request is local and when it is a remote
user. The default implementation of local_request? is:
def local_request? #:doc:
@request.remote_addr == "127.0.0.1"
end
So a request will be considered local if it comes from the local
machine. Otherwise it will be considered remote. Local requests are
given the stack trace. Remote requests are given the custom error page
(/public/500.html).
The documentation and information on all this is on:
/vendor/actionpack/lib/action_controller/base.rb:192-196
/vendor/actionpack/lib/action_controller/rescue.rb:54-59
Hope that helps!
Eric
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 187 bytes
Desc: OpenPGP digital signature
Url : http://one.textdrive.com/pipermail/rails/attachments/20050111/a2901b8a/signature.bin
More information about the Rails
mailing list