I have my first Rails app running and I regularly get the following
“logged_exception” error message:
“ActionController::InvalidAuthenticityToken”
Has anybody an idea what might cause this problem? Could it somehow be a
“time out” error (like an “AuthenticityToken” which might expire after a
certain time, or something along those lines)?
Any idea how that error could be prevented from occurring?
The Authenticity Token is a value that is inserted in to forms (when
using
the form_for helper) that is then checked when the submit request is
sent.
It helps prevent CSRF attacks.
What is likely happening is that you’re generating your own form and not
including the token (which you can do by inserting a hidden field and
using
the authenticity_token helper).
You can learn more about CSRF and Rails’ protection at:
Cheers,
Andy
–
Andy J. http://andyjeffries.co.uk/#rubyonrails#mysql#jquery
Registered address: 64 Sish Lane, Stevenage, Herts, SG1 3LS
Company number: 5452840
Yeah, Andy is right. Why don’t you send us the code that generates these
error requests? I have seen this error in some Ajax components like
autocomplete. They create a form but do not send the token.
Have you cached your view by any chance? That would mean that the
authenticity_token in the view is stored in a cached file and not really
dynamic?
Cheers,
Aditya
Tom Ha wrote:
Hi there,
I have my first Rails app running and I regularly get the following
“logged_exception” error message:
“ActionController::InvalidAuthenticityToken”
Has anybody an idea what might cause this problem? Could it somehow be a
“time out” error (like an “AuthenticityToken” which might expire after a
certain time, or something along those lines)?
Any idea how that error could be prevented from occurring?
We’ve had it happen on random occasions while using the RESTful
authentication plugin after upgrading Rails. I remember reading a
ticket issue somewhere about it and iirc it has to do with something
funky in reset_session. But since we had the need for Rack-based
authentication as well as some other features, we switched to Devise
and have had no error reports ever since.