Rails updatedat not updating dating in robert ga
I'm not talking about the invalid record problem anymore, only the problem with an update undoing changes from another update. I added a lock_version column, so Rails will automatically do optimistic locking.The form will have two fields, a checkbox to indicate if the employee is a manager, and a field to enter a salary.
Let's add another column to the employees table, employee_of_the_month_votes, an integer.That means that even if only a single user is changing the employee's management status or salary, the update will fail if between the time when the user opened the edit page, made his changes, and submitted the form, somebody else voted for the employee as employee of the month. It's also more likely to happen the longer the user takes to make his edits.I was talking to Philippe about this, and he summarized it well: I'm not saying that you shouldn't use optimistic locking.It will preserve user 1's changes and reject user 2's.Another solution is to keep the object in memory so that the update action will perform the update on the same object that the edit action used to render the form.