check_box for Noob


This doesn’t work for you?

<% for @prod_detail in @product.prod_detail %>

Color:<%= prod_detail.color %> Size:<%= prod_detail.size %>

Price:<%= prod_detail.price %>
<%= check_box (“prod_detail”,“available”) %>

<% end %>

Notice some changes to your code

You had

<% for prod_detail in @product.prod_detail %>

I have

<% for @prod_detail in @product.prod_detail %>

Secondly, you had

<%= check_box (“available”, prod_detail.available) %>

I had

<%= check_box (“prod_detail”, “available”) %>

Notice that the check_box takes two params + options… OBJECT, METHOD. If you want “prod_detail.available” you use it just like a text field

I have similar code in an app I’m using right now and it works fine… no need for strange workarounds as the check_box helper already adds a hidden field to handle those situations where the value is uncheked.

The helpers like text_field, etc expect an instance variable (defined with @) to do some of their magic. You’ll run into this a lot.