I''d like to extend optimistic locking to habtm associations. Considering just the DB, I think it could work like this: Take the three tables employees, tasks, and employees_tasks. In addition to the foreign keys relating rows in the two other tables, employees_tasks gets a lock_version attribute. For each row in employees, there must be at least one row in employees_tasks at all times; when no task is associated to a specific employee, then there''s a single row with the employee_id == employee.id and task_id == NULL. On updating the association for Employee emp, here''s what happens (in a transaction): emp.tasks.clear, delete all rows from employees_tasks where j.employee_id == emp.id and j.lock_version == whatever the expected lock_version. If not at least one row is deleted, as indicated by the SQL return value, the emp.tasks is stale and an exception is thrown. If all goes well, new objects are pushed into the association. My problem right now is that I don''t see how to put this to work with ActiveRecord. The two major problems are: (1) HasAndBelongsToMany#clear returns the association object, not the delete count. (2) The lock_version field from the employees_tasks overwrites the attribute of the same name in Employee. For consistency, it would be good to use the name "lock_version" in the join table, too. IMHO join table fields should be prefixed with the association name anyway when merged into the associated object. Rails being written in Ruby, I could program around any of these obstacles. There comes a point, though, when I''m not working with Rails, but against it. And I fear that point is reached here. I appreciate your ideas and suggestions. Michael -- Michael Schuerig Failures to use one''s frontal lobes mailto:michael-q5aiKMLteq4b1SvskN2V4Q@public.gmane.org can result in the loss of them. http://www.schuerig.de/michael/ --William H. Calvin