title: Parameter not being passed to partial
body: <p>I have a Rails 4 application where user accounts can be created in two ways: by new users (sign up) or by admin users (add account).</p>
  
  <p>My thought process was to send all requests to the new action in the User controller, have some logic in there to see if it's a new user or an admin user and handle the request accordingly. Here's my template:</p>
  
  <p><strong>new_by_admin.html.erb:</strong></p>
  
  <pre><code>&lt;%= form_for(@user) do |f| %&gt;
      &lt;div class="col-md-6 col-md-offset-3"&gt;
          &lt;h1 class="centertext"&gt;Add User&lt;/h1&gt;
          &lt;%= render 'add_user_fields', f: f %&gt;
  
          &lt;%= f.submit "Create account", class: "btn btn-large btn-primary" %&gt;
      &lt;/div&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <p>In the controller, this works fine:</p>
  
  <p><strong>user_controller.rb:</strong></p>
  
  <pre><code>def new
      @user = User.new
      if !signed_in?
          @user.confirmation_code = User.new_confirmation_code
      elsif signed_in? &amp;&amp; current_user.admin?
          new_by_admin
      else
          redirect_to root_url
      end
  end
  
  def new_by_admin
      @user = User.new
  end
  </code></pre>
  
  <p>However, the below code throws a "First argument in form cannot contain nil or be empty" error in the template, presumably because @user is nil.</p>
  
  <pre><code>def new
      @user = User.new
      if !signed_in?
          @user.confirmation_code = User.new_confirmation_code
      elsif signed_in? &amp;&amp; current_user.admin?
          render 'new_by_admin', user: @user
      else
          redirect_to root_url
      end
  end
  </code></pre>
  
  <p>What is the difference between these, and why doesn't the second method work even though I'm passing the @user object as a parameter to the partial?</p>