# How to lock a row and all its associated rows

**URL:** <https://www.ruby-forum.com/t/how-to-lock-a-row-and-all-its-associated-rows/141877>\
**Category:** Rails\
**Created:** [July 1, 2008, 10:36am UTC](https://www.ruby-forum.com/t/how-to-lock-a-row-and-all-its-associated-rows/141877 "2008-07-01T10:36:19Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![fries88](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/6bbea6/32.png) [@fries88](https://www.ruby-forum.com/u/fries88)\
**Post date:** [July 1, 2008, 10:36am UTC](https://www.ruby-forum.com/t/how-to-lock-a-row-and-all-its-associated-rows/141877/1 "2008-07-01T10:36:19Z")

</div>

Hi,

I have a profile table, module table and book table. A profile has many  
modules, a module has many books. Module belongs to profile and book  
belongs to module.

When a user accesses a profile, the profile and the associated modules  
and books will be locked. Meaning that other users cannot edit or delete  
this profile and the associated modules and books.

How can I achieve that? Someone please help.

Thanks

---

<div class="post-metadata">

**Author:** ![fries88](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/6bbea6/32.png) [@fries88](https://www.ruby-forum.com/u/fries88)\
**Post date:** [July 1, 2008, 11:56am UTC](https://www.ruby-forum.com/t/how-to-lock-a-row-and-all-its-associated-rows/141877/2 "2008-07-01T11:56:41Z")

</div>

On 1 Jul 2008, at 09:36, user splash wrote:

> delete  
> this profile and the associated modules and books.
> 
> How can I achieve that? Someone please help.

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

---

<div class="post-metadata">

**Author:** ![fries88](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/6bbea6/32.png) [@fries88](https://www.ruby-forum.com/u/fries88)\
**Post date:** [July 1, 2008, 3:25pm UTC](https://www.ruby-forum.com/t/how-to-lock-a-row-and-all-its-associated-rows/141877/3 "2008-07-01T15:25:01Z")

</div>

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.

On Jul 1, 5:56 am, Frederick C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
