1

In my Rails 4 project I want to add 2 fields to all the forms for a controller on the server side.

I'd like to add this to all of my forms for a controller.

input name="authenticity_token" type="hidden" value='=form_authenticity_token'
input name="profilePage" type="hidden" value='#{params[:action]}'

Each view has one form.

Mika Tuupola
  • 19,877
  • 5
  • 42
  • 49
David Silva Smith
  • 11,498
  • 11
  • 67
  • 91

1 Answers1

2

You could make it a partial:

#_csrf.html.slim
input name="authenticity_token" type="hidden"value='=form_authenticity_token'
input name="profilePage" type="hidden" value='#{params[:action]}'

And then render it in each form:

= render 'csrf'
trosborn
  • 1,658
  • 16
  • 21