check_box not being checked

I'm new to RoR and I'm having a little problem that I can't solve.

My model is simple. I have Lists and ListItems.

I have a view that loops through all the list items, and I put the
HTML for the each list item row in a partial called _list_item.rhtml.

This is the view, called show.rhtml

<ul>
<%= render(:partial => "list_item", :collection => @list.list_items)
%>
</ul>

And this is the partial _list_item.rhtml

<li>
<%= check_box 'list_item', 'done' %>
<%= list_item.text %>
</li>

As you can see, my list_item has two fields: done and text.

The problem is that even though the field done is an integer "1" I
can't get the checkbox to get checked!!!

The rest works as expected.

Any idea? Thanks!

BTW, same thing happens if I don't use a partial.

Try putting this at the top of your partial:

<% @list_item = list_item %>

The magic form helper methods rely on instance variables to set the
value. Alternatively, you could do this:

<%= check_box_tag "list_item[done]", list_item.done %>

Michael Bleigh
michael@intridea.com