title: Using simple_form, how do I render a 'new' form on the view of another controller in a DRY way?
body: <p>I have a <code>_form.html.erb</code> partial, for my <code>DailyEntry</code> model that looks like this:</p>
  
  <pre><code>&lt;%= simple_form_for(@daily_entry) do |f| %&gt;
    &lt;%= f.error_notification %&gt;
  
    &lt;div class="form-inputs"&gt;
      &lt;%= f.input :breakfast %&gt;
      &lt;%= f.input :snack_1 %&gt;
      &lt;%= f.input :lunch %&gt;
      &lt;%= f.input :snack_2 %&gt;
      &lt;%= f.input :dinner %&gt;
      &lt;%= f.input :water_intake %&gt;
      &lt;%= f.input :workout %&gt;
      &lt;%= f.input :notes %&gt;
    &lt;/div&gt;
  
    &lt;div class="form-actions"&gt;
      &lt;%= f.button :submit %&gt;
    &lt;/div&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <p>Each <code>DailyEntry</code> belongs to a <code>User</code>...i.e. each <code>daily_entry</code> record has a <code>user_id</code> column.</p>
  
  <p>I would like for the <code>current_user</code> to be able to add a <code>daily_entry</code> from the <code>Home#Index</code> page - WITHOUT duplicating the <code>create</code> action of my <code>DailyEntry</code> controller.</p>
  
  <p>So how do I kill 2 birds with one stone? i.e. assign the newly created <code>daily_entry</code> record to the current user, and then also have this all done from my <code>views/home/index.html.erb</code>?</p>
  
  <p><strong>Edit 1</strong></p>
  
  <p>I know how to assign each record to a user....in the <code>DailyEntry</code> controller <code>create</code> action, I have this:</p>
  
  <pre><code>def create
    @daily_entry = current_user.daily_entries.create(params[:daily_entry])
  
  respond_to do |format|
    if @daily_entry.save
      format.html { redirect_to @daily_entry, notice: 'Daily entry was successfully created.' }
      format.json { render json: @daily_entry, status: :created, location: @daily_entry }
    else
      format.html { render action: "new" }
      format.json { render json: @daily_entry.errors, status: :unprocessable_entity }
    end
   end
  end
  </code></pre>
  
  <p>I am just not sure how to get this done from my <code>Home#Index.html.erb</code>. How do I render this form without duplicating that controller logic in my <code>HomeController</code>?</p>
  
  <p><strong>Edit 2</strong></p>
  
  <p>I also tried this:</p>
  
  <pre><code>&lt;%= render partial: "daily_entries/form", @daily_entry =&gt; current_user.daily_entries.build  %&gt;
  </code></pre>
  
  <p>But I still get this error:</p>
  
  <pre><code>NoMethodError at /
  undefined method `model_name' for NilClass:Class
  </code></pre>
  
  <p>At line:</p>
  
  <pre><code>&lt;%= simple_form_for(@daily_entry) do |f| %&gt;
  </code></pre>