# Group countries per continent

**URL:** <https://www.ruby-forum.com/t/group-countries-per-continent/187596>\
**Category:** Rails\
**Created:** [April 26, 2010, 4:51pm UTC](https://www.ruby-forum.com/t/group-countries-per-continent/187596 "2010-04-26T16:51:34Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![pubclub](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/3d9bf3/32.png) [@pubclub](https://www.ruby-forum.com/u/pubclub)\
**Post date:** [April 26, 2010, 4:51pm UTC](https://www.ruby-forum.com/t/group-countries-per-continent/187596/1 "2010-04-26T16:51:34Z")

</div>

Hi guys,

I have a table that has a country column (:string). Now I need to group  
together all the countries that are in Europe.

Any ideas on how I would approach this? (quickfix wise)

Regards,

Vincent

---

<div class="post-metadata">

**Author:** ![pubclub](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/3d9bf3/32.png) [@pubclub](https://www.ruby-forum.com/u/pubclub)\
**Post date:** [April 26, 2010, 5:38pm UTC](https://www.ruby-forum.com/t/group-countries-per-continent/187596/2 "2010-04-26T17:38:23Z")

</div>

On Mon, Apr 26, 2010 at 7:51 AM, Vincent B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> I have a table that has a country column (:string). Now I need to group  
> together all the countries that are in Europe.
> 
> Any ideas on how I would approach this? (quickfix wise)

1. Add continent as an attribute to Country, access collections via  
named scope

2. Create a Continent model where Continent has\_many countries,  
Country belongs\_to continent

## HTH,

Hassan S. ------------------------ removed\_email\_address@domain.invalid  
twitter: @hassan
