How to lock a row and all its associated rows

Set a flag on the profile to indicate it is being edited (or perhaps the user id of the editor so that you can say 'locked by bob') and disallow edits based on that.

Fred

Peripheral observation: I'm going to be surprised if you don't have a
problem with the 'module table' at some point since 'module' is a
reserved word in Ruby.