search for: get_new_messag

Displaying 1 result from an estimated 1 matches for "get_new_messag".

Did you mean: get_new_messages
2006 Jun 27
2
Avoiding race conditions
I want to be able to display a number of messages, and guarantee that they''re only displayed once. Something like this : def get_new_messages @messages = Message.find(:all, :limit => 5, :conditions => ''new = 1'') @messages.each do |msg| msg.new = 0 msg.save end end However, there''s a race condition in the above code if two users try to access the get_new_messages action at the same time. How...