Created
September 24, 2013 23:11
-
-
Save statianzo/6692603 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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