Question: I have the following code:

```
@countries = Country.find( :all, :order => 'name' )

@countries_with_tips = []

@countries.each do |country|
  if country.tips.any?
    @countries_with_tips.push( country )
  end
end

```

I am getting each country that has at least one tip. A country has\_many tips and a tip belongs\_to a country

It works. But for Ruby it seems a little unelegant. Is there a better way?

Thanks in advance

Richard

Answer: 
```
@countries_with_tips = Country.joins(:tips).order(:name).uniq

```
```
@countries_with_tips = @countries.select{|country| country.tips.present? }

```