aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_view/helpers/csrf_helper.rb
blob: 6f98bd457385ae596b46bc71b98b19031cfbad92 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
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-param" content="#{Rack::Utils.escape(request_forgery_protection_token)}"/>\n<meta name="csrf-token" content="#{Rack::Utils.escape(form_authenticity_token)}"/>).html_safe
        end
      end
    end
  end
end