I have in a form (form_tag) several checkboxes like this:
<%=check_box_tag \'model_name[column_name]\', 1, (@data.model_name.column_name == 1
This happens because an unchecked checkbox will not send any value to the server. To circumvent this Rails provides the check_box helper, which generates code like this:
Alternatively, insert a hidden field with hidden_field_tag
:
<%= hidden_field_tag 'model_name[column_name]', '0' %>
<%= check_box_tag 'model_name[column_name]', 1, (@data.model_name.column_name == 1 ? true : false) %>