Join list where ID is repeated in one table?

I have a (legacyDB) table where ID is kept on updates, but the “active”
column is set to 0 or 1. The primary key is a constraint of ID and
Version

ID Version Active Name
1 1 0 machineA
1 2 0 machineA
1 3 1 machineA

so I query this with
@machines = Machine.find( :all, :conditions => “Active=‘1’”)

however in my join list

<% @pools.each do |pool| %>
<% for machine in pool.machines %><%= machine.Name %><% end %><% end %>

I get the same machine listed for as many records as there are machines
with that ID (which makes perfect sense to Rails because it’s the DB
design that is nutty)

if machineA has 3 entries (2 not active and 1 active) I get machineA
listed 3 times for the pools that it’s in.

is there a way to limit pool.machines to just the active machine?

thanks
-zac

On 8/24/06, Zac E. [email protected] wrote:

so I query this with

if machineA has 3 entries (2 not active and 1 active) I get machineA
listed 3 times for the pools that it’s in.

is there a way to limit pool.machines to just the active machine?

I think what you’re looking for is the :conditions option on your
model association. Check the docs for ActiveRecord.

– James