I''ve notice some entries in the log where folks are just poking around. Is it possible to ''trap'' these and redirect_to something valid like the site''s home page? Thanks, Bill --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Bill Walton wrote:> I''ve notice some entries in the log where folks are just poking around. > Is it possible to ''trap'' these and redirect_to something valid like the > site''s home page?Sure. I''m working on a site right the requirements to visit a specified page can be complex. I use something at the top of each method like bad_action and return if ... where the "if" clause includes a set of conditions anybody visiting a specific page must meet (@user_logged_in, !params[''id''].blank?, etc.) bad_action simply redirects to the index page or, if the user is logged in, to the user home page. --Al Evans -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hi Al, Thanks for your reply. More below. Al Evans wrote:> Bill Walton wrote: >> I''ve notice some entries in the log where folks are just poking around. >> Is it possible to ''trap'' these and redirect_to something valid like the >> site''s home page? > > Sure. I''m working on a site right the requirements to visit a specified > page can be complex. I use something at the top of each method like > > bad_action and return if ...I''ve got before_filters in place for that sort of thing. What I was thinking / wondering about is something at a higher level that would catch attempts to invoke controllers / actions that don''t exist. I guess I''m asking ''is there some way to redirect to a valid page (like the site''s home page) rather than just throwing a 404 ''Page not found''? I''m guessing I should have marked this [OT] now that I think about it. It''s probably something that has to happen outside the Rails app. I just don''t know enough about the architecture to know where the ''trap'' should be set. Where / what decides that a 404 error gets thrown and that it should display 404.html? Is it configurable so that I could set it to display my home page instead? Thanks, Bill --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Bill Walton wrote:> I''ve got before_filters in place for that sort of thing. What I was > thinking / wondering about is something at a higher level that would > catch > attempts to invoke controllers / actions that don''t exist. I guess I''m > asking ''is there some way to redirect to a valid page (like the site''s > home > page) rather than just throwing a 404 ''Page not found''?I think you can do... map.connect '''', :controller => "whatever", :action => "home" ...at the end of your routes and catch all unrecognized controllers/actions. I haven''t had occasion to do this, though. I don''t think it would work for the case where the controller is recognized, but the action isn''t. --Al Evans -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---