Give focus to an input field of a form

I am new to rails and I have setup Typo on my site. One little
thing bugs me, the login page doesn’t give focus to the “user_login”
field. I was wondering what do I need to do to make rails help with
this? I have seen some simple inline javascript to set the focus,
sort of like:


However the rails view doesn’t have name for the form, so that code
won’t work. Below is the code for the login.rhtml from Typo:

<% form_tag :action=> “login” do %>


<div class="form admin">
  <% if flash[:notice] %>
    <h4><%= flash[:notice] %></h4>
  <% end %>
      <label for="user_login" class="block"><%= _('Username')%>:</


  • <%= _(‘Password’)

  • »" class="primary" />

    <%= link_to "« " + _(‘Back to the blog’), { :controller
    => ‘/articles’ } %>

    <% end %>

    I want to give focus to the user_login field when the page loads. Any


    any one?

    found the answer elsewhere:

    This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

    | Privacy Policy | Terms of Service | Remote Ruby Jobs