Hello all,

I'm having some trouble with a 'Has One/Belongs To' association I'm
trying to set up.  Here's the gist of it:

I have an IP Network model (IpNetwork) and a Layer 3 Network model
(Layer3Network).  Each model has an ':id' field.  For every IP Network
I create, I also want a Layer 3 Network to exist - thus my 'Has One/
Belongs To' association.

# IpNetwork model:
class IpNetwork
  include DataMapper::Resource

  property :id, Serial
  property :address, String

  belongs_to :layer3_network, :child_key => ['id']
end

# Layer3Network model:
class Layer3Network
  include DataMapper::Resource

  property :id, Serial

  has 1, :ip_network, :child_key => ['id]
end

Now, when I do the following:

ip_net = IpNetwork.new :address => '10.0.0.1'
ip_net.layer3_network.create
ip_net.save

I get the following:

ip_net.inspect # ==> <IpNetwork id=1, address='10.0.0.1'>
ip_net.new_record? # ==> false
ip_net.layer3_network.inspect # ==> <Layer3Network id=1>
ip_net.layer3_network.ip_network.inspect # ==> <IpNetwork id=1,
address=nil>

Why does the address show up when I access the IpNetwork object
directly, but not when I access it via the Layer 3 Network?!

--
Thanks!
Bryan
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to