Hello, I want my 404 and 500 pages to use the application layout, so they look like the rest of my site. So, I''m doing this def rescue_action_in_public(exception) logger.error("rescue_action_in_public executed") case exception when ActiveRecord::RecordNotFound, ::ActionController::UnknownAction, ::ActionController::RoutingError render(:file => "#{RAILS_ROOT}/public/404.html", :layout => ''application'', :status => "404 Not Found") #SystemNotifier.deliver_exception_notification( # self, request, exception) else render(:file => "#{RAILS_ROOT}/public/500.html", :layout => ''application'', :status => "500 Error") #SystemNotifier.deliver_exception_notification( # self, request, exception) end end But, it only works at the root level. If you go to http://www.pawsitiveapproach.ca/foobar, then you get the main layout on the 404 page. But, if you go to http://www.pawsitiveapproach.ca/articles/foobar, you don''t. Is this just a routing issue? Here are my routes. ActionController::Routing::Routes.draw do |map| # With no path provided, default to the front page. map.connect '''', :controller => "main", :action => ''index'' # Route for the admin section. map.connect ''/admin/petfacts/:action/:id'', :controller => ''admin_petfact'' map.connect ''/admin/testimonials/:action/:id'', :controller => ''admin_testimonial'' map.connect ''/admin/articles/:action/:id'', :controller => ''admin_article'' map.connect ''/admin/users/:action/:id'', :controller => ''admin_users'' map.connect ''/admin/'', :controller => ''admin'', :action => ''index'' # Map for the top-level, so we don''t see ''main'' in the URLs. map.connect ''/:action/:id'', :controller => "main", :requirements => { :id => /^\d+$/ } # Standard route. map.connect '':controller/:action/:id'' end Also, how do you catch routing errors? I''m trying to in my exception handler above, but it''s not working. Thanks, Mike --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
what version of Rails are you using? I''m running edge rails right now (changeset 5533) and having a similar problem. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
pjkelly wrote:> what version of Rails are you using? I''m running edge rails right now > (changeset 5533) and having a similar problem.you can render 404 but not 500 if you get a 500 error your application is not served. just create an error controller with 404 action -- 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 -~----------~----~----~----~------~----~------~--~---
I was doing the same thing msoulier is doing above by trying to catch RecordNotFound and RoutingErrors with rescue_action_in_public but it seems to be broken in Edge Rails. It worked fine in 1.1.6. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
With the code below, is it now working in 1.2? And where would this def go?? Blessed Be Phillip msoulier wrote:> Hello, > > I want my 404 and 500 pages to use the application layout, so they look > like the rest of my site. So, I''m doing this > > def rescue_action_in_public(exception) > logger.error("rescue_action_in_public executed") > case exception > when ActiveRecord::RecordNotFound, > ::ActionController::UnknownAction, > ::ActionController::RoutingError > render(:file => "#{RAILS_ROOT}/public/404.html", > :layout => ''application'', > :status => "404 Not Found") > #SystemNotifier.deliver_exception_notification( > # self, request, exception) > else > render(:file => "#{RAILS_ROOT}/public/500.html", > :layout => ''application'', > :status => "500 Error") > #SystemNotifier.deliver_exception_notification( > # self, request, exception) > end > end > > But, it only works at the root level. If you go to > http://www.pawsitiveapproach.ca/foobar, then you get the main layout on > the 404 page. But, if you go to > http://www.pawsitiveapproach.ca/articles/foobar, you don''t.-- 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 -~----------~----~----~----~------~----~------~--~---