mikrogroove
2010-Mar-30 10:40 UTC
How to deal with array of checkbox values in Ruby 1.9.1?
In Ruby 1.9.1 strings are no longer enumerable and string.each is undefined. This causes a problem when parsing values for an array of generated checkboxes since the field value, when submitted, becomes an array of strings. For example: <% for map in Map.find(:all) %> <%= check_box_tag "listing[map_ids][]", map.id, @listing.maps.include? (map) %> <%= map.title %> <% end %> This will result in an error, undefined method `each'' for "1":String, in process_parameter_filter because map_ids is being passed as "map_ids"=>["1","2"] (if checkboxes with values 1 and 2 have been checked that is). What is the recommended way to fix this? -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.