In "char.location.npcs" the char object is trying to access the location's npc object collection (hence the plural form. the location class has n npc objects). irb does show that no SELECT query is geting run everytime I try to query that parent collection... when i exit out of irb and come back in i see the correct char.location.npcs.count (and members). The odd thing is that when I see this happen: char.location.npcs.size ! = char.location.npcs.count and, of course, npc.location.npcs != char.location.npcs (which they should, right?)
On Dec 29, 12:57 pm, RailinAndWailin <waugustyn...@gmail.com> wrote: > 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 datamap...@googlegroups.com. To unsubscribe from this group, send email to datamapper+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/datamapper?hl=en.