5

As per the rails docs, using the submit_tag helper will generate something like

submit_tag
# => <input name="commit" type="submit" value="Save changes" />

It includes the property name="commit"

  • Why does this get included? Is it some sort of standard? Trying to understand what "commit" means in this context

  • I noticed it gets included in the params inside the controller after hitting submit. Was this changed recently? I thought only url params and POST/PUT data get included?

    @params

    => {"utf8"=>"✓", "authenticity_token"=>"4q3u+mfMi57YbchTAzaCI7WHmzfZJrLbTZ17aVwfq9uw8aMU1B3PBR13qfipgN6lbRoi0dywFU9i1AbJ0GP7UA==", "email"=>"foo@example.co", "password"=>"(REDACTED)", "dest"=>"", "commit"=>"Log in", "controller"=>"sessions", "action"=>"log_in"}

Thanks!

user2490003
  • 10,706
  • 17
  • 79
  • 155

1 Answers1

3

I believe this is just a rails thing. HTML5 standards allow you to provide a name=xxxx on your own, which you can also do with rails. In short, name="commit" helps in case you need to do something like this guy and makes sure something is passed in the parameters.

Community
  • 1
  • 1
Godzilla74
  • 2,358
  • 1
  • 31
  • 67