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"=>"[email protected]", "password"=>"(REDACTED)", "dest"=>"", "commit"=>"Log in", "controller"=>"sessions", "action"=>"log_in"}
Thanks!
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With