In HTML5, you can do something like this:
<%= f.text_field :my_field, :autofocus => true %>
The only way to achieve this without using HTML 5 is with JavaScript, if I'm not mistaken. This has nothing to do with Rails; it is an HTML attribute.
Cimm
source share