Hi all, Sometime, I get the following error in my application: ActionController::InvalidAuthenticityToken in ManageController#site_servers ActionController::InvalidAuthenticityToken I tried to put the code in manage controller between begin ... rescue ... end but it didn''t catch the error. So I tried in the application.rb controller, I put the forgery code between begin ... rescue ... end, but it didn''t work neither. How could I trap this error ? -- 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 -~----------~----~----~----~------~----~------~--~---
On 2 Sep 2008, at 13:15, MR Damien wrote:> > Hi all, > > Sometime, I get the following error in my application: > > ActionController::InvalidAuthenticityToken in > ManageController#site_servers > ActionController::InvalidAuthenticityToken > > I tried to put the code in manage controller between begin ... rescue > ... end but it didn''t catch the error.The exception is raised before your action runs, so an rescue block inside your action would do nothing. if you meant class ... begin def some_action end end end then that would only catch exceptions raised while ruby was loading the controller file (not when it was processing the request> > So I tried in the application.rb controller, I put the forgery code > between begin ... rescue ... end, but it didn''t work neither. >ditto> How could I trap this error ?see rescue_action_in_public; rescue_from Fred --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Frederick Cheung wrote:> On 2 Sep 2008, at 13:15, MR Damien wrote: > >> ... end but it didn''t catch the error. > The exception is raised before your action runs, so an rescue block > inside your action would do nothing. if you meant > > class ... > begin > def some_action > end > end > end > > then that would only catch exceptions raised while ruby was loading > the controller file (not when it was processing the request > >> >> So I tried in the application.rb controller, I put the forgery code >> between begin ... rescue ... end, but it didn''t work neither. >> > ditto >> How could I trap this error ? > > see rescue_action_in_public; rescue_from > > FredI got it to work with rescue_from but the redirection (redirect_to(:controller => "login" )) I am doing is only done inside a little box using Ajax. How could I tell the navigator to reload the whole page ? -- 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 -~----------~----~----~----~------~----~------~--~---
On 4 Sep 2008, at 14:55, MR Damien <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > Frederick Cheung wrote: >> On 2 Sep 2008, at 13:15, MR Damien wrote: >> >>> ... end but it didn''t catch the error. >> The exception is raised before your action runs, so an rescue block >> inside your action would do nothing. if you meant >> >> class ... >> begin >> def some_action >> end >> end >> end >> >> then that would only catch exceptions raised while ruby was loading >> the controller file (not when it was processing the request >> >>> >>> So I tried in the application.rb controller, I put the forgery code >>> between begin ... rescue ... end, but it didn''t work neither. >>> >> ditto >>> How could I trap this error ? >> >> see rescue_action_in_public; rescue_from >> >> Fred > > I got it to work with rescue_from but the redirection > (redirect_to(:controller => "login" )) I am doing is only done > inside a > little box using Ajax. > > How could I tell the navigator to reload the whole page ?Render some rjs that does page.redirect_to (which just generates window.location=...)> > -- > 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 -~----------~----~----~----~------~----~------~--~---
Frederick Cheung wrote:> On 4 Sep 2008, at 14:55, MR Damien <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> > wrote: > >>> def some_action >>>> >> little box using Ajax. >> >> How could I tell the navigator to reload the whole page ? > > Render some rjs that does page.redirect_to (which just generates > window.location=...)Thanks for the help :) -- 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 -~----------~----~----~----~------~----~------~--~---