When using javascript in Rails in order to fill in forms and remain on the same page, it is nice if after submitting and resetting the form, the focus is set back on the first element of the form. In order to do this, you can simply use the following piece of JS in your file.js.erb:

1
$("input:text:visible:first").focus();