aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_view/helpers
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2010-02-04 14:15:16 -0800
committerJeremy Kemper <jeremy@bitsweat.net>2010-02-04 14:58:32 -0800
commit78de17cf7095af8e86d192af8d8fbe21e6f193d9 (patch)
treee8fe545aea289d059f9eac3d0bf335586a149576 /actionpack/lib/action_view/helpers
parent127e53453dc52e07aff877212e204084f7321529 (diff)
downloadrails-78de17cf7095af8e86d192af8d8fbe21e6f193d9.tar.gz
rails-78de17cf7095af8e86d192af8d8fbe21e6f193d9.tar.bz2
rails-78de17cf7095af8e86d192af8d8fbe21e6f193d9.zip
Expose CSRF tag for UJS adapters
Diffstat (limited to 'actionpack/lib/action_view/helpers')
-rw-r--r--actionpack/lib/action_view/helpers/csrf_helper.rb12
1 files changed, 12 insertions, 0 deletions
diff --git a/actionpack/lib/action_view/helpers/csrf_helper.rb b/actionpack/lib/action_view/helpers/csrf_helper.rb
new file mode 100644
index 0000000000..2d6af52180
--- /dev/null
+++ b/actionpack/lib/action_view/helpers/csrf_helper.rb
@@ -0,0 +1,12 @@
+module ActionView
+ module Helpers
+ module CsrfHelper
+ # Returns a meta tag with the request forgery protection token for forms to use. Put this in your head.
+ def csrf_meta_tag
+ if protect_against_forgery?
+ %(<meta name="csrf-token" content="#{Rack::Utils.escape(form_authenticity_token)}"/>).html_safe
+ end
+ end
+ end
+ end
+end