Hi Jon, Thanks for the reply and sorry for taking so long to get back to you.
It turns out that I was inadvertently using dm-constraints as I was using require 'data_mapper' The default value is 'protect' so it was refusing to delete my lists. I've not changed this to :destroy and it works fine. I just have a couple of questions: 1) Do you have to use dm-constraints when using associations? 2) Is there any way of getting DM to report the reason why it hasn't deleted the list in the console so it is easier to figure out why it isn't doing something in future? cheers, DAZ On Oct 1, 7:13 pm, Jonathan Stott <[email protected]> wrote: > Hi DAZ > > Use dm-constraints, is the short answer. > > This sets up true database level foreign key references, which default > to protect, but can be set to cascade deletes instead. > > class List > has n, :todos, :constraint => :destroy (or :destroy!) > end > > Regards > Jon > > On 28 September 2010 21:12, DAZ <[email protected]> wrote: > > > > > Hi, > > > I have a simple task and list combo: > > > class Task > > belongs_to :list > > end > > > class List > > has n, :tasks > > end > > > If I try this: > > List.first.destroy > > => false > > > But if I try this: > > List.first.destroy! > > => true > > > Is the reason I can't use the destroy method to delete a list because > > it has some child tasks? If so, how can I set the models up so that > > destroy would remove the list AND its tasks? > > > cheers, > > > DAZ -- 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.
