Try the following:
Country.where(:country_code => "uy").collect(&:cities)
What you are missing:
Check out this error:
undefined method `cities' for #<ActiveRecord::Relation:0x007f8e92ca0df0>
where the condition returns an array of objects. For example (in some cases 1 id is present)
Country.first
Country.find(1)
Country.where(:id=> 1)
So,
Country.find(1) IS NOT EQUAL TO Country.where(:id=> 1)
But
Country.find(1) IS EQUAL TO Country.where(:id=> 1).first
Here are the basics. So the problem was
Country.where(:country_code => "uy")
, "" , . , , "", , "" .
:
Country.where(:country_code => "uy")
:
['a','b','c','d']
Country.where(:country_code => "uy").collect(&:cities)
:
[[1,2,3,4],[2,3,6,8],[8],[10]] ie an array of an array.
, :
Country.where(:country_code => "uy").collect(&:cities).flatten
, ( , , , , ), .uniq .