Understanding the Rails Authenticity Token

前端 未结 10 1005
攒了一身酷
攒了一身酷 2020-11-22 05:55

I am running into some issues regarding the Authenticity Token in Rails, as I have many times now.

But I really don\'t want to just solve this problem and go on. I w

10条回答
  •  南笙
    南笙 (楼主)
    2020-11-22 06:40

    What is an authentication_token ?

    This is a random string used by rails application to make sure that the user is requesting or performing an action from the app page, not from another app or site.

    Why is an authentication_token is necessary ?

    To protect your app or site from cross-site request forgery.

    How to add an authentication_token to a form ?

    If you are generating a form using form_for tag an authentication_token is automatically added else you can use <%= csrf_meta_tag %>.

提交回复
热议问题