In a form I have a list of products from database and every product has these items in the form:
= text_field_tag 'item['+product.id.to_s+'][]'
= text_field_tag 'item_value1['+product.id.to_s+'][]'
= text_field_tag 'item_value2['+product.id.to_s+'][]'
I am trying to loop over the array and get all those (item, item_value1, item_value2) this way:
params[:item].each_with_index do |val, index|
puts "#{val[0]} => #{val[1]}"
end
and the output is like:
191359 => [""]
191361 => [""]
191360 => ["15"]
191212 => [""]
191210 => ["9"]
248974 => [""]
191209 => [""]
190920 => [""]
190919 => [""]
190921 => [""]
But, how to get all data for the respective products? Something like
puts "item: #{item}, item_value1: #{item_value1}, item_value2: #{item_value2}"