Rails: How Does csrf_meta_tag Work?

后端 未结 5 1698
灰色年华
灰色年华 2020-12-07 18:43

I\'m a PHP developer learning Ruby on Rails by reading Michael Hartl\'s tutorial. Here is a quote from the book, referring to csrf_meta_tag:

5条回答
  •  半阙折子戏
    2020-12-07 18:56

    csrf_meta_tag is basically fulfilling the same thing as hidden form fields but is there to give javascript requests that aren't tied to a form an easy way of getting the token.

    If you use the jquery-ujs library the content of that meta tag is automatically added (as a request header) to any ajax requests made.

提交回复
热议问题