Help, please. 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). Thanks. ___________________________________ Nuovo Yahoo! Messenger: E'' molto più divertente: Audibles, Avatar, Webcam, Giochi, Rubrica Scaricalo ora! http://it.messenger.yahoo.it
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 _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
i have some trouble with links, about trailing ''/'' e.g. redirect_to ''/login/index'' in internet explorer becomes ''/login/index/'' ; also using the form :controller => login, :action => index. With Mozilla, all ok. Another problem is than with ''/login/index/'' the browser enter in ''listing-mode'', how can i avoid this problem (no-listing mode)? There is a way to always ''chomp'' the last "/"? ___________________________________ Nuovo Yahoo! Messenger: E'' molto più divertente: Audibles, Avatar, Webcam, Giochi, Rubrica Scaricalo ora! http://it.messenger.yahoo.it
I''ve changed the property consider_all_requests_local to false. Now for remote requests the output is the standard "Application error (Rails)", but it isn''t the content of /public/500.html: h1>Application error (Apache)</h1> <p>Change this error message for [...]</p> It is the default output of a method / another file located... where? Thank you in advance. --- Eric Anderson <eric-ANzg6odk14w@public.gmane.org> ha scritto:> 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 >> ATTACHMENT part 1.2 application/pgp-signaturename=signature.asc> _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >___________________________________ Nuovo Yahoo! Messenger: E'' molto più divertente: Audibles, Avatar, Webcam, Giochi, Rubrica Scaricalo ora! http://it.messenger.yahoo.it
I''ve changed the property consider_all_requests_local to false. Now for remote requests the output is the standard "Application error (Rails)", but it isn''t the content of /public/500.html: h1>Application error (Apache)</h1> <p>Change this error message for [...]</p> It is the default output of a method / another file located... where? Thank you in advance. --- Eric Anderson <eric-ANzg6odk14w@public.gmane.org> ha scritto:> 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 >> ATTACHMENT part 1.2 application/pgp-signaturename=signature.asc> _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >___________________________________ Nuovo Yahoo! Messenger: E'' molto più divertente: Audibles, Avatar, Webcam, Giochi, Rubrica Scaricalo ora! http://it.messenger.yahoo.it
I''ve changed the property consider_all_requests_local to false. Now for remote requests the output is the standard "Application error (Rails)", but it isn''t the content of /public/500.html: h1>Application error (Apache)</h1> <p>Change this error message for [...]</p> It is the default output of a method / another file located... where? Thank you in advance. --- Eric Anderson <eric-ANzg6odk14w@public.gmane.org> ha scritto:> 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 >> ATTACHMENT part 1.2 application/pgp-signaturename=signature.asc> _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >___________________________________ Nuovo Yahoo! Messenger: E'' molto più divertente: Audibles, Avatar, Webcam, Giochi, Rubrica Scaricalo ora! http://it.messenger.yahoo.it
Raffaele Tesi wrote:> I''ve changed the property consider_all_requests_local > to false. Now for remote requests the output is the > standard "Application error (Rails)", but it isn''t the > content of /public/500.html: > > h1>Application error (Apache)</h1> > <p>Change this error message for [...]</p> > > It is the default output of a method / another file > located... where?It''s probably because you are using Webrick. You may have to check the Webrick documentation for how to set a custom 500 error message. Rails is generating a 500 error message. In Apache when it sees the 500 response it loads /public/500.html because of the .htaccess telling it to. I assume there is some way to tell Webrick to load a certain file if the application generates a 500 message, but I don''t know enough about Webrick to know how to do that. Eric _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
i see webrick_servlet.rb (required by public/dispatch_servlet) unless handle_mapped(req, res) raise WEBrick::HTTPStatus::NotFound, "`#{req.path}'' not found." end and this an output example: ERROR `/mainn.html'' not found. Obviously i can simply write one line of code to wrap the exception but... what about _Rails_ exceptions? Webrick generates the message only when i request a page (*.html) not present, but when i "request" a nonexistent controller i think is Rails to manage the exception... There is a way to handle the exception? I report the stacktrace, grabbed from the log file, relative to the request of the nonexistent "mainn" controller. Processing Base#index (for 10.1.1.244 at Wed Jan 12 10:23:30 CET 2005) Parameters: {"action"=>"index", "controller"=>"mainn"} LoadError (No such file to load -- mainn_controller.rb): /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.1.0/lib/action_controller/dependencies.rb:46:in `load'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.1.0/lib/action_controller/dependencies.rb:46:in `require_dependency'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.1.0/lib/action_controller/dependencies.rb:46:in `silence_warnings'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.1.0/lib/action_controller/dependencies.rb:46:in `require_dependency'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.1.0/lib/action_controller/dependencies.rb:2:in `require_dependency'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.1.0/lib/action_controller/dependencies.rb:2:in `require_dependency'' /usr/local/lib/ruby/gems/1.8/gems/rails-0.9.2/lib/dispatcher.rb:37:in `dispatch'' /public/dispatch.rb:10 /usr/local/lib/ruby/gems/1.8/gems/rails-0.9.2/lib/webrick_server.rb:101:in `load'' /usr/local/lib/ruby/gems/1.8/gems/rails-0.9.2/lib/webrick_server.rb:101:in `handle_dispatch'' /usr/local/lib/ruby/gems/1.8/gems/rails-0.9.2/lib/webrick_server.rb:80:in `handle_mapped'' /usr/local/lib/ruby/gems/1.8/gems/rails-0.9.2/lib/webrick_server.rb:34:in `do_GET'' /usr/local/lib/ruby/1.8/webrick/httpservlet/abstract.rb:35:in `__send__'' /usr/local/lib/ruby/1.8/webrick/httpservlet/abstract.rb:35:in `service'' /usr/local/lib/ruby/1.8/webrick/httpserver.rb:92:in `service'' /usr/local/lib/ruby/1.8/webrick/httpserver.rb:54:in `run'' /usr/local/lib/ruby/1.8/webrick/server.rb:150:in `start_thread'' /usr/local/lib/ruby/1.8/webrick/server.rb:144:in `start'' /usr/local/lib/ruby/1.8/webrick/server.rb:144:in `start_thread'' /usr/local/lib/ruby/1.8/webrick/server.rb:94:in `start'' /usr/local/lib/ruby/1.8/webrick/server.rb:89:in `each'' /usr/local/lib/ruby/1.8/webrick/server.rb:89:in `start'' /usr/local/lib/ruby/1.8/webrick/server.rb:79:in `start'' /usr/local/lib/ruby/1.8/webrick/server.rb:79:in `start'' /usr/local/lib/ruby/gems/1.8/gems/rails-0.9.2/lib/webrick_server.rb:19:in `dispatch'' script/server:49 Thanks in advance --- Eric Anderson <eric-ANzg6odk14w@public.gmane.org> ha scritto:> Raffaele Tesi wrote: > > I''ve changed the property > consider_all_requests_local > > to false. Now for remote requests the output is > the > > standard "Application error (Rails)", but it isn''t > the > > content of /public/500.html: > > > > h1>Application error (Apache)</h1> > > <p>Change this error message for [...]</p> > > > > It is the default output of a method / another > file > > located... where? > > It''s probably because you are using Webrick. You may > have to check the > Webrick documentation for how to set a custom 500 > error message. Rails > is generating a 500 error message. In Apache when it > sees the 500 > response it loads /public/500.html because of the > .htaccess telling it > to. I assume there is some way to tell Webrick to > load a certain file if > the application generates a 500 message, but I > don''t know enough about > Webrick to know how to do that. > > Eric >> ATTACHMENT part 1.2 application/pgp-signaturename=signature.asc> _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >___________________________________ Nuovo Yahoo! Messenger: E'' molto più divertente: Audibles, Avatar, Webcam, Giochi, Rubrica Scaricalo ora! http://it.messenger.yahoo.it