title: Devise form within a different controller
body: <p>I am using a devise gem for sign_in/sign_out procedures.</p>
  
  <p>I generated views files from devise, using <code>rails g devise views</code></p>
  
  <p>I saw there was a devise/sessions/new.html.erb file which contained a form for sign_in.</p>
  
  <p>I created another file devise/sessions/_form.html.erb and did <code>&lt;%= render 'form' %&gt;</code> within a new.html.erb file, and that worked out very fine.</p>
  
  <p>Now, I wanted to include this form from the different controller. So in a controller called 'main', (specifically, within view page) 'mains/index.html.erb' I included <code>&lt;%= render 'devise/sessions/form' %&gt;</code> file. It seems that inclusion worked fine, but I am getting the following error.</p>
  
  <pre><code>NameError in Mains#index
  
  Showing /home/administrator/Ruby/site_v4_ruby/app/views/devise/sessions/_form.html.erb where line #1 raised:
  
  undefined local variable or method `resource' for #&lt;#&lt;Class:0x007f1aa042d530&gt;:0x007f1aa042b870&gt;
  Extracted source (around line #1):
  
  1: &lt;%= form_for(resource, :as =&gt; resource_name, :url =&gt; session_path(resource_name)) do |f| %&gt;
  2:   &lt;p&gt;&lt;%= f.label :email %&gt;&lt;br /&gt;
  3:   &lt;%= f.text_field :email %&gt;&lt;/p&gt;
  4: 
  </code></pre>
  
  <p>It seems that form_for(resource,...) part is causing the problem (which works fine if I am on the original devise sign_in page... How can I resolve this problem in rails way?</p>
  
  <p>I personally prefer to use 'render' function to include the form, rather than writing html codes inline.</p>
  
  <p>Do I have to specify something (resource) within the 'main' controller? </p>
  
  <p>I will appreciate your help. Thank you.</p>