MilesTogue, > # db has one user, no contacts yet > > @user = User.first # returns first user > if @user.contacts => error condition dependent does not map to > relationship in Contact > > shouldn't it return false ? I can wrap this with a test for contacts > but like to avoid extra code if possible.
This should return an empty Collection (a Collection is like an Array of persisted resources). In this case you want to use Collection#any? and Collection#empty? (inherited from Enumerable), eg: if @user.contacts.any? # do something if there are *any* contacts end if @user.contacts.empty? # do something if there are *no* contacts end -- Dan Kubb (dkubb) --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "DataMapper" group. To post to this group, send email to datamapper@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 -~----------~----~----~----~------~----~------~--~---