I have an interesting situation and I am wondering if I can trap just this specific error... undefined method `[]'' for nil:NilClass which comes the user is trying to access a controller method which assumes session variables that no longer exist because the session has timed out. I would rather bounce them to a static web page than toss the application error in this case. Is this possible? -- Craig White <craig-CnJ8jr4MGtxl57MIdRCFDg@public.gmane.org> --~--~---------~--~----~------------~-------~--~----~ 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 have an interesting situation and I am wondering if I can trap just > this specific error... > > undefined method `[]'' for nil:NilClass > > which comes the user is trying to access a controller method which > assumes session variables that no longer exist because the session has > timed out. > > I would rather bounce them to a static web page than toss the > application error in this case. Is this possible?Yes... begin #access the session that errors out rescue redirect_to ''/somewheresafe'' end Or test it using nil? before calling [] on it... --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---