I’m making a musicians site where the users are able to check some
checkboxes with their music-style if they want to edit their music-style
i would like the previous checked checkboxes to be checked.
here’s some code
<%= label %>:
<%= check_box_tag array, db_field, @status %> <%= db_field %> | <% if @i == 1 %> <% @i = -1 %>
collection could be:
VALID_STYLES = [“Blues”, “Country”, “Elektronisk”, “Folkemusik”,
“Hip-Hop”,
“Jazz”, “Klassisk”, “Metal”, “Pop”, “R&B og Soul”,
“Rock”,
“Verdensmusik”]
and the db_collection could be:
Blues, Elektronisk, R&B og Soul
I don’t know why, but with the code i have now R&B og Soul would get
updated in the view so that the checkbox would be checked, it’s always
the last option that gets checked.