Missing? has_and_belongs_to_many with a has_one relationship----the tool/helper

In a dual boot computer the hardware has_and_belongs_to_many OS’s,
each os has only 1 set of hardware–how ever this is not has_many,
belongs_to as the OS does not belong to the hardware, it serves only
as the conduit.

I see no way to express this in rails–its a reverse has_many,
belongs_to, and is really just a semantics difference—but putting
belongs to where it doesnt belong makes things ugly because you put
labels on things that dont make sense.

any help? did i just no find the awnser or does this really not exist?

I’m not sure to understand exactly what you mean, but i’m afraid there
isn’t other way to express what you described.
It sound logical to say that a given Os instance could be linked to
only one set of hardware. And of course a given set of hardware can
“see” many Os running (sometime in the mean time!!). So it looks like
a has_many-belongs_to association.

But you can imagine a Conduit object that can be used as a join table:

class Harware < ActiveRecord
:has_many :conduits
:has_many :os, througt => :conduits
end

class Os < ActiveRecord
:has_one :conduit
:has_one :hardware, :througt => :conduit
end

class Conduit < ActiveRecord
:belongs_to :conduit
:belongs_to :os
end

I’m not sure it works exactly like that, but hope it helps

Mathieu BODIN