[Nitro] og: automatic deletion of records in M:N relations?

Stephan Mueller d454d at web.de
Sun Aug 20 12:08:32 EDT 2006


it seems to me og is not deleting records in helper tables in case the
'master' record/object is deleted:

Let's say i have two classes:

class Item
	# ...
	many_to_many Tag
	# ...

class Tag
	# ...
	many_to_many Item
	# ...

Creating items and tags just works as intended. But when there are items
deleted, in the mapping table (eg. ogj_item_tag) the records for the
deleted items don't get removed automatically. Inserting new objects can
lead to problems and resulting exceptions due to the remaining entries
in the mapping table.

This can be circumvented by deleting tags first like this:

item.tags.each { | t | item.remove_tag(t) }

but in my opion this should be handled by og without any help by the
programmer. The remaining records in the mapping table are useless anyway 
because the references are broken.

Is there a better way to handle this kind of situation?



More information about the Nitro-general mailing list