I am implementing a checkboxlist with some items and next to each item there is a dropdown. These two things hang together and what i want to do is to create a hash, the key is the value or id from the checked item, the value is the value of the selected item in the dropdown.
This is what i have:
view:
<% @groups.each do |group| %>
<li>
<%= check_box_tag 'group[]', group.id -%>
<%= h group -%>
<%= select_tag 'role_group[group.id][]', options_for_select(@roles) %>
</li>
<% end %>
controller:
@selected_groups = Group.find(params[:group])
@selected_roles = params[:role_group]
@roleskeys = @selected_roles.keys
Now if i show @roleskeys , he always just say group.id. So this is not correct, this is just the string. Somebody who knows what i am doing wrong?
Try it this way:
You will have both together in a Hash.