Module: ActionView::Helpers::CsrfHelper

Included in:
ActionView::Helpers
Defined in:
lib/action_view/helpers/csrf_helper.rb

Instance Method Summary collapse

Instance Method Details

#csrf_meta_tagObject

Returns a meta tag with the cross-site request forgery protection token for forms to use. Place this in your head.



7
8
9
10
11
# File 'lib/action_view/helpers/csrf_helper.rb', line 7

def csrf_meta_tag
  if protect_against_forgery?
    %(<meta name="csrf-param" content="#{Rack::Utils.escape_html(request_forgery_protection_token)}"/>\n<meta name="csrf-token" content="#{Rack::Utils.escape_html(form_authenticity_token)}"/>).html_safe
  end
end