Alex Rivera | Logout

Understanding the Rails Authenticity Token

Asked 2009-06-02T20:01:38.163
1066

What is the Authenticity Token in Rails?

Edit
Report

1 Answer

150

The authenticity token is designed so that you know your form is being submitted from your website. It is generated from the machine on which it runs with a unique identifier that only your machine can know, thus helping prevent cross-site request forgery attacks.

If you are simply having difficulty with rails denying your AJAX script access, you can use

<%= form_authenticity_token %>

to generate the correct token when you are creating your form.

You can read more about it in the documentation.

answered 2009-06-02T20:16:53.107

Your Answer