I hope this isn't something I'm doing out of ignorance:

class Location
...
has n, :characters
has n, :npcs

class Character
..
belongs_to :location

class Npc
...
belongs_to :location

>>char=Character.new
>>loc=Location.new
>>loc.characters<<char
>>char.save
>>char.location
=><#Location @id=1...>
>>char.location.npcs
=>[ ]
>>npc=Npc.new
>>loc.npcs<<npc
>>npc.save

Now, why does this happen? :

>>char.location.npc
=>[ ]

Still empty, even though:

>>npc.location
=><#Location @id=1...>
>>npc.location.characters
>>[<#Character @id ... >]

The thing that I notice is that whe i query the collection as
"char.location.npcs" I don't see a SQL query going out (as though its
looking at a chache), though when I "char.locatin.npcs.count" I get
the proper return as 1 (and a query going out).

help a noob understand?

--

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