The class with belongs_to will get the ID. So just make it:

class Class0  include Datamapper::Resource
  property :id, Serial
  belongs_to :class1
end

class Class1
  include Datamapper::Resource
  property :id, Serial
  has n, :class0
end

..tony..


On Fri, Jan 30, 2009 at 7:55 AM, Lucas Kloster <[email protected]>wrote:

>  Thanks tony...
> I'm sorry, i made a mistake with the navigability of the association...
>
>     -------------      *                1    ------------
>   |    Class0    |       ----------->    |    Class1    |
>     -------------                              ------------
>
> If I define this in this way:
> class Class0
>     include DataMapper::Resourse
>           ----  properties -----
>     has 1, :class1
> end
>
> class Class0
>     include DataMapper::Resourse
>           ----  properties -----
>      belongs_to :class0
> end
>
> in the class1s table is the class0_id, but I need the class1_id in the
> class0s table...
>
> I hope you can understand, i'm not good with english, i'm in Argentina...
>
> Thanks...
>
>
>
>
> Tony Mann escribió:
>
> class Class1   include Datamapper::Resource
>   property :id, Serial
>   belongs_to :class0
> end
>
>  class Class0
>   include Datamapper::Resource
>   property :id, Serial
>    has n, :class1
> end
>
> On Fri, Jan 30, 2009 at 3:57 AM, Lucas Kloster <[email protected]>wrote:
>
>> Hello, i'm starting with ruby and DataMapper...
>> How can I define this association?:
>>
>>     -------------      *               1     ------------
>>   |    Class0    |      < -----------    |    Class1    |
>>     -------------                              ------------
>>
>> I need in the class1s table the class0_id...
>>
>> Thanks!
>>
>> --
>> Lucas Kloster
>>  [email protected]
>>
>>
>
> >
>
>
> --
> Lucas Kloster
>  [email protected]
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"DataMapper" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/datamapper?hl=en
-~----------~----~----~----~------~----~------~--~---

<<inline: 666bbfc4e2584a314d95e11e732d98c9.png>>

<<image/png>>

Reply via email to