title: Same form for Edit and New methods
body: <p>I want to use same html form for <code>Edit</code> and <code>New</code> methods.</p>
  
  <p>Controller methods:</p>
  
  <pre><code>def new 
      render "edit"
  end
  
  def edit
    if params[:id].present?
      @goat = Goat.find(params[:id])
    else
      @goat = Goat.new
    end
  end
  </code></pre>
  
  <p><code>Edit</code> form:</p>
  
  <pre><code>&lt;% form_for @goat do |f| %&gt;    
  &lt;%= f.text_field :title %&gt; 
  &lt;%= f.submit "Update" %&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <p>It works well for <code>Edit</code> method when @goat record exists, but for <code>New</code> method, when controller gives <code>@goat = Goat.new</code> I got an error: </p>
  
  <p><code>undefined method model_name for NilClass:Class</code></p>
  
  <p>How to fix this?</p>