protect_from_forgery & Unobtrusive Javascript

Posted by Matt Grande on Stack Overflow See other posts from Stack Overflow or by Matt Grande
Published on 2009-04-08T19:41:16Z Indexed on 2010/04/28 3:23 UTC
Read the original article Hit count: 257

Filed under:
|
|

Hi all,

I have some javascript making an ajax call in my Rails site:

$.ajax({type: "PUT", url: url, data: { dummy: data }, complete: function(data) {}});

When Rails gets it, it throws back an ActionController::InvalidAuthenticityToken Error. I'd like to keep the protect_from_forgery stuff in there, if possible... But I'm at a loss for how can I pass the auth token from a javascript file?

Can anyone help me out?

© Stack Overflow or respective owner

Related posts about ruby-on-rails

Related posts about jQuery