Rescue rails errors

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 ?

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

Frederick Cheung wrote:

Frederick Cheung 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=...)

Frederick Cheung wrote: