title: Ruby on Rails - Trouble looping through partial using collection
body: <p>I am having issues using the :collection command for a partial within a form I am creating in rails. I would ideally like to use the :collection command, so I can easily manipulate this section in my .rjs templates (the form will submit and reload the form when the check box is changed, it's a to-do list).</p>
  
  <p>This code works:</p>
  
  <pre><code>&lt;% form_for "list[]", :url =&gt; {:action =&gt; "checkbox_update"} do |f| %&gt;
        &lt;ul id="lists_not_completed"&gt;
             &lt;% for @list in @lists %&gt;
                 &lt;%= render :partial =&gt; @list,  :locals =&gt; {:f =&gt;f, :complete =&gt; FALSE } %&gt;   
            &lt;% end %&gt;
        &lt;/ul&gt;
  &lt;% end %&gt;   
  </code></pre>
  
  <p>with the partial:</p>
  
  <pre><code>&lt;% if @list.completed == complete %&gt;
          &lt;li&gt;&lt;%= f.check_box :completed %&gt;
                  &lt;%=h @list.name %&gt;
  
          &lt;%= link_to 'Show', list %&gt;
          &lt;%= link_to 'Edit', edit_list_path(list) %&gt;
      &lt;%= link_to 'Destroy', list, :confirm =&gt; 'Are you sure?', :method =&gt; :delete %&gt;&lt;/li&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <p>This code does not work, but I would like it to use this form:</p>
  
  <pre><code>&lt;% form_for "list[]", :url =&gt; {:action =&gt; "checkbox_update"} do |f| %&gt;
    &lt;ul id="lists_not_completed"&gt;
        &lt;%= render :partial =&gt; 'list', :collection =&gt; @lists, :locals =&gt; {:f =&gt;f, :complete =&gt; FALSE } %&gt; 
    &lt;/ul&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <p>with the non-working partial:</p>
  
  <pre><code>&lt;% if list.completed == complete %&gt;
          &lt;li&gt;&lt;%= f.check_box :completed %&gt;
                  &lt;%=h list.name %&gt;
  
          &lt;%= link_to 'Show', list %&gt;
          &lt;%= link_to 'Edit', edit_list_path(list) %&gt;
      &lt;%= link_to 'Destroy', list, :confirm =&gt; 'Are you sure?', :method =&gt; :delete %&gt;&lt;/li&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <p>I get the error: </p>
  
  <p>object[] naming but object param and @object var don't exist or don't respond to to_param: nil. It is referring to this line: <code>&lt;li&gt;&lt;%= f.check_box :completed %&gt;</code>. I'm not sure if why this doesn't work and have tried many, many different variations, but I can't get it working. Is the form preventing me from doing this? The form_for code is straight from the Rails Way book for listing multiple objects from one model in a form.</p>
  
  <p>Any help on this would be greatly appreciated. </p>