<p>Let's say I have the following code:</p>

<pre><code>@sites = Site.find(session[:sites]) # will be an array of Site ids
@languages = Language.for_sites(@sites)
</code></pre>

<p>for_sites is a named_scope in the Language model that returns the languages associated with those sites, and languages are associated with sites using has_many through. The goal is for @languages to have a distinct array of the languages associated with the sites.</p>

<p>Instead of calling the Language object on the second line, I'd ideally like to say </p>

<pre><code>@sites.languages
</code></pre>

<p>and have the same list returned to me. Is there any way to do that cleanly in Rails 2.1 (or edge)? I know associations and named scopes can extend the array object to have attributes, but unless I'm missing something that doesn't apply here. Any plugins that do this would be welcome, it doesn't have to be in core.</p>

Your instance variable @sites is an Array object and not Site so I don't think named_scope can be used. You can open up Array class to achieve this effect though (yikes)
```
```
class Array

  def languages
    ...
  end

end
```
```