So I have been struggling with an issue for a while now and seem to be
getting nowhere...
The problem exists while I am looping through a hash, around the 3rd level
deep.
So my code looks a little like:
request[:items][:location_item].each do |locaton_item|
pp location_item[:name]
location_item[:items][:sub_area_option_item].each do
|sub_area_option_item|
pp sub_area_option_item[:name]
sub_area_option_item[:items][:option_item].each do |option_item|
option_item[:name] <- THIS IS WHERE MY CODE BREAKS
end
end
end
The reason this is failing is because this particular part of the loop has
2 different variants, one where there is an infinite amount of
"option_items" and one where there is only one
"option_item". Instead of
sending me back the single "option_item" it is looping through this
"option_item" and not finding this particular field. Any ideas as how
to
force it when only one object is found to still return it as an array?
--
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
To view this discussion on the web visit
https://groups.google.com/d/msg/rubyonrails-talk/-/LBJ_zzBpvTIJ.
For more options, visit https://groups.google.com/groups/opt_out.