Reputation: 1143
I'm curious about best practice when it comes to updating a domain object that may be updated by multiple sessions.
The call that occurs is AJAX from the g:remoteField tag. It takes the value and updates a domain object:
person.refresh()
person.isLeader = true
person.save(flush:true)
I added a refresh prior to the update, since the value could be different.
Is this the best way to handle this? Is there a better way to handle updating? I don't particularly care if two people update at the same time in this scenario.
Upvotes: 1
Views: 310
Reputation: 31280
In general, I prefer to let the optimistic locking do it's job and override it where I explicitly don't care if users stomp on each others' changes. (Note: these cases are few and far between)
What this means for highly ajaxy sites is that you have to have very solid error handling to cover update conflicts.
Upvotes: 1