I need a checkbox to be preselected based off of a users response to a question. I wrote the code to handle the saving of responses and the method using "includes?" to set a true or false value for the "checked" option of the check_box_tag. However, the check_box_tag refuses to premark the checkbox as true no matter what I do. I've reviewed almost every question and response similar to my question and none of the answers have worked. I simplified my code to the following to cut out as many of the variables I could think of:
<% options.each do |option| %>
<%= check_box_tag "test", 1, true %>
<%= option.description %>
<% end %>
The check boxes are displayed with the option descriptions, but the check box still isn't pre-checked. Is there a piece to this I'm missing?
inspect elements shows this:
input checked="checked" id="test" name="test" type="checkbox" value="1"
This particular portion of code is within a partial where I'm passing in the params via locals(if that helps).
Using Rails 3.2 and Ruby 1.9.3
This is a similar issue to but with collection_check_boxes How to pre-populate collection_check_boxes in an edit form?
I appreciate your time in checking this out with me =)
Aucun commentaire:
Enregistrer un commentaire