public
Created

How to Build A Secure Website With Ruby On Rails 2

  • Download Gist
csrf.js
JavaScript
1 2 3 4 5 6 7 8
var form_data = //.. Serialise a form
 
// Get token and param from the meta tags
var token = $('meta[name="csrf-token"]').attr('content');
var param = $('meta[name="csrf-param"]').attr('content');
 
// Create url of "/settings/profile?name=Jeremy+Walker&authenticity_token=askdsalewg303y09sd00dshb0b00ac0dffbafds"
document.location = "/settings/profile?_method=PUT&" + form_data + "&" + token + "=" + param;

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.