Rails 4. How to add authenticity_token to forms rendered via partial? Rails 4. How to add authenticity_token to forms rendered via partial? ruby-on-rails ruby-on-rails

Rails 4. How to add authenticity_token to forms rendered via partial?


In your case, we have two ways to do:

  1. Add authenticity_token: true in form options

  2. Manually add authenticity_token field into form, like this:

<%= hidden_field_tag :authenticity_token, form_authenticity_token -%>


Ok, so it seems it's about remote forms and not forms loaded via a partial:

Changed default value for config.action_view.embed_authenticity_token_in_remote_forms to false. This change breaks remote forms that need to work also without JavaScript, so if you need such behavior, you can either set it to true or explicitly pass authenticity_token: true in form options.

Found answer here: https://github.com/rails/rails/issues/10608