datamapper secondary key

Posted by Luc on Stack Overflow See other posts from Stack Overflow or by Luc
Published on 2010-01-13T13:50:36Z Indexed on 2010/03/25 2:23 UTC
Read the original article Hit count: 575

Filed under:
|

Hello, I am using datamapper in a ruby application and I'm facing a problem I do not understand.

I have a Appartment model and a Location model. An appartment is at a given location and several appartments can be at the same location. This typically described a 1-n relationship (I guess :-) )

My feeeling is that in the Appartement sql table I need a location_id but I do not want any Appartment pointers within the Location table. For me, Location should live on its own and should not reference appartment.

In the Appartement ruby class, I have added:

has n, Location

but it then creates an appartment_id within the Location ruby class, which I do not want.

Would you have any clue ?

Thanks a lot, Luc

© Stack Overflow or respective owner

Related posts about datamapper

Related posts about ruby