Skip to content

Instantly share code, notes, and snippets.

@statianzo
Created September 24, 2013 23:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save statianzo/6692603 to your computer and use it in GitHub Desktop.
Save statianzo/6692603 to your computer and use it in GitHub Desktop.
module CsrfHelpers
def token
session[:csrf] ||= SecureRandom.hex(32)
end
def csrf_input_tag
%Q(<input type="hidden" name="authenticity_token" value="#{token}" />)
end
def csrf_meta_tag
%Q(<meta name="_csrf" content="#{token}" />)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment