title: How to put a login form in the header for Devise and Rails
body: <p>I want to put a login form in the header of my website. I use Rails 3.2.8 and the latest Devise. In the <code>app/views/devise/sessions/new.html.erb</code> file a login form is created with:</p>
  
  <pre><code>  &lt;%= form_for(resource, :as =&gt; resource_name, :url =&gt; session_path(resource_name), :html =&gt; {:class =&gt; 'main'}) do |f| %&gt;
      &lt;div&gt;&lt;%= f.label :login %&gt; &lt;%= f.text_field :login, :placeholder =&gt; 'Enter username' %&gt;&lt;/div&gt;
      &lt;div&gt;&lt;%= f.label :password %&gt; &lt;%= f.password_field :password, :placeholder =&gt; 'Enter password' %&gt;&lt;/div&gt;
      &lt;% if devise_mapping.rememberable? -%&gt;
        &lt;div&gt;&lt;%= f.check_box :remember_me %&gt; &lt;%= f.label :remember_me %&gt;&lt;/div&gt;
      &lt;% end -%&gt;
      &lt;%= f.submit "Go" %&gt;
    &lt;% end %&gt;
  </code></pre>
  
  <p>If I try to copy that code and put it in my <code>application.html.erb</code>, I get an error regarding that resource variable referenced above:</p>
  
  <pre><code>undefined local variable or method `resource' for #&lt;#&lt;Class:0x3cb62c8&gt;:0x3c73b00&gt;
  </code></pre>
  
  <p>So can I just use a normal rails form with <code>/users/sign_in</code> as the action? How do I tell devise where to redirect to after logging in?</p>