How to create forms with React and Rails?

You can paste authenticity_token into react component.

Using gem react-rails

= react_component 'Form', authenticity_token: form_authenticity_token

form_authenticity_token is the rails helper.

So you can paste it into your form.

<form role="form" accept-charset="UTF-8" action='/action' method='post'>
  <input type="hidden" name="authenticity_token" value={this.props.authenticity_token} />

It’s not the best solution. I would be happy if someone will tell a better solution.

Leave a Comment