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.

Reply via email to