我在考虑是否有可能多个用户提交表单导致数据被覆盖。这是按时间顺序排列的动作流:
1. User 1 clicks on Edit, rails render the page that has <form> and has value {A: 1, B: 2}
2. User 2 clicks on Edit, rails render another page that has <form> and has value {A: 1, B: 2}
3. User 1 updates value A to 5 and clicks on Submit, passing to server {A: 5, B: 2}
4. Server updates to database to {A: 5, B: 2}
5. User 2 updates value B to 10 and clicks on Submit, passing to server {A: 1, B: 10}
6. Server updates to database to {A: 1, B: 10}
由于用户 2 的浏览器有旧数据。当B点击提交时,字段A作为1过去。用户1的更新被覆盖。
我如何在rails中解决这个问题?