Displaying 1 result from an estimated 1 matches for "starting_up".
Did you mean:
starting_r
2009 May 19
4
proper way to ensure atomic model changes
Hi!
Say we have a rails active-record-based model called "instance" which
can have different states - STOPPED, RUNNING, STARTING_UP,
SHUTTING_DOWN, etc...
There is a method #start which changes the instance state to
STARTING_UP only if it is STOPPED.
def start
if self.state == STOPPED
self.state = STARTING_UP
self.save
...
end
end
As you understand if we have multiple concurrent requests for #start,
there is a p...