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 ?

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

Frederick C. 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 ?

On 4 Sep 2008, at 14:55, MR Damien [email protected]
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=…)

Frederick C. wrote:

On 4 Sep 2008, at 14:55, MR Damien [email protected]
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 :slight_smile:

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs