The error occurs when I try to delete the a model "Model_Tmgroup"
The relationship is/should be as follows:
tmuser 1 ----- M tmfriend
tmuser 1 ----- M tmgroup (tmusers may own many groups)
tmfriend M -- M tmgroup (tmgroups may have many friends, and each friend may belong to many groups) Note, group owners may only add friends to their groups
What happens is pretty obvious, you have configured cascade_delete on your belongs_to between group and users. Which basically means, that when you delete a agroup, it will delete all associated users.
Normally, you never use cascade_delete on a belongs_to, as that is a relation from child to parent, and enabling it would delete the parent when you delete the child. If you want cascading, you want it the other way around, delete a parent, then cascade and delete it's children.
This is very dependent on the situation offcourse. For example, When deleting an order record, you would also want to delete all order lines belonging to that order. But when you delete a library member, you never want to delete all books borrowed by that member. They remain library books, even if no one has borrowed them at a given point in time.