Skip to content

Instantly share code, notes, and snippets.

@bonyiii
Created March 22, 2012 13:14
Show Gist options
  • Save bonyiii/2158289 to your computer and use it in GitHub Desktop.
Save bonyiii/2158289 to your computer and use it in GitHub Desktop.
Rails ajax link_to remote with put, post
http://www.kolodvor.net/2010/01/02/rails-csrf-and-ajax-requests/
http://api.rubyonrails.org/classes/ActionController/RequestForgeryProtection/ClassMethods.html#M000514
http://stackoverflow.com/questions/5241213/rails-session-is-blank-when-using-http-put
Key thing is to add form_authenticity_token to path param as a query_string
http://api.rubyonrails.org/classes/ActionView/Helpers/UrlHelper.html#method-i-link_to
<%= link_to 'Reset', null_counter_model_path(model, :authenticity_token => form_authenticity_token), :confirm => 'Are you sure?', :method => :put, :remote => true %>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment