Skip to content

Instantly share code, notes, and snippets.

@stuartc
Created October 18, 2014 12:33
Show Gist options
  • Save stuartc/081931c855978cb554d3 to your computer and use it in GitHub Desktop.
Save stuartc/081931c855978cb554d3 to your computer and use it in GitHub Desktop.

Revisions

  1. stuartc created this gist Oct 18, 2014.
    5 changes: 5 additions & 0 deletions disable-csrf-and-sessions-for-json
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,5 @@
    class MyController < ApplicationController
    protect_from_forgery with: :null_session, if: Proc.new { |c| c.request.format == 'application/json' }

    # ...
    end