In reference to this
I’ve created a question in a webform like this:
<div class='form_row'> <label for='features[]'>Features:</label> <% [ 'scenarios', 'role_profiles', 'private_messages', 'polls' ].each do |feature| %> <br><%= check_box_tag 'features[]', feature, (params[:features] || {}).include?(feature) %> <% end %> </div>
So if scenarios and private_messages gets checked and I print out params[:features] I will get: scenariosprivate_messages
I was wondering how would I be able to obtain scenarios and private_messages separately from params. Is the mapping params[:features] = 'scenariosprivate_messages' or is it really params[features] = ['scenarios', 'private_messages'] ? If it’s the latter how can I loop through them?
I write in my view:
<%= params[:features].each {|param| param.capitalize } %>
and I still just get scenariosprivate_messages printed.
Try this instead:
The problem with your original solution is that you’re printing out the result of the block, which is the array itself, rather than printing out each element of the array.