In rails I’ve seen code like
form_for(@post, html: {:class => "foo"})
but sometimes rails auto converts any key it doesn’t recognize to html?
In the above instance, if you don’t use the :html key, the class assignment won’t be reflected in the DOM.
when to use this?
According to the documentation you should use the html option whenever you want to add attributes to the form tag:
“:html – Optional HTML attributes for the form tag.”
There are other pre-defined options that rails can pick up. There are quite a lot. You can see exactly which in the documentation.