title: How do I pass data to a partial?
body: <p>K guys, so I created this up/down vote script (basically like the one here on stackoverflow), and I'm trying to add some Ajax to it, so that the page doesn't reload everytime you vote. </p>
  
  <p>I have two controllers, one called grinders, and one called votes. (Grinders are basically posts)</p>
  
  <p>So here's the index of all the grinders (Looks like this ) <img src="https://i.stack.imgur.com/3g1fM.jpg" alt="Screenshot."></p>
  
  <p>and here's the code to that page. </p>
  
  <pre><code>&lt;/head&gt;
  &lt;body&gt;
   &lt;h1&gt;Listing grinders&lt;/h1&gt;
  
   &lt;%= render(:partial =&gt; "grinders/grinders")%&gt;
  &lt;br /&gt;
  
  &lt;%= link_to 'New grinder', new_grinder_path %&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>and this is what I have in the views/grinders/_grinders.erb</p>
  
  <pre><code>&lt;% @grinders.each do |grinder| %&gt;
  
  &lt;div id="main"&gt;
      &lt;div style="float:left; height:80px; width:50px"&gt;
          &lt;div class='up'&gt;
              &lt;% form_for(@vote, :remote =&gt; true) do |u|%&gt;
                  &lt;%= u.hidden_field :grinder_id, :value =&gt; grinder.id %&gt;
                  &lt;%= u.hidden_field :choice, :value =&gt; "up" %&gt;
                  &lt;%= image_submit_tag("http://i13.photobucket.com/albums/a287/Rickmasta185/arrow-small-green-up.png", :class =&gt; 'create') %&gt;
  
              &lt;% end %&gt;  
          &lt;/div&gt;
          &lt;center&gt;&lt;%= grinder.votes_sum %&gt;&lt;/center&gt;
          &lt;div class='down'&gt;
              &lt;% form_for(@vote, :remote =&gt; true) do |d|%&gt;
                  &lt;%= d.hidden_field :grinder_id, :value =&gt; grinder.id %&gt;
                  &lt;%= d.hidden_field :choice, :value =&gt; "down" %&gt;
                  &lt;%= image_submit_tag("http://i13.photobucket.com/albums/a287/Rickmasta185/arrow-small-red-down.png", :class =&gt; 'create') %&gt;
              &lt;% end %&gt;  
          &lt;/div&gt;
  
      &lt;/div&gt;
  
  
      &lt;div class='box' &gt;"&lt;strong&gt;It grinds our gears &lt;/strong&gt;&lt;%=h grinder.grinder %&gt;"&lt;/div&gt;
  
  
  
   &lt;/div&gt;
  &lt;/div&gt;
  
  &lt;% end %&gt;
  </code></pre>
  
  <p>But everytime I try to vote for one, I get the following error: </p>
  
  <blockquote>
    <p>You have a nil object when you didn't expect it!
    You might have expected an instance of Array.
    The error occurred while evaluating nil.each
    <img src="https://i.stack.imgur.com/x4qEl.jpg" alt="Screenshot of error.">
    I've tried soo many things, and I just cannot get it  to work! (Larger screenshot - <a href="http://grab.by/7bgb" rel="noreferrer">http://grab.by/7bgb</a>)</p>
  </blockquote>
  
  <p>Any help? If you need anymore information, just ask!</p>