[email protected] wrote:
> what i need:
> if :record is in the database -> upgrade his counter
> else create :record (with his counter on 1)
> 
> this should be done with an atomic operation, to avoid race
> conditions.
> What is the best way to do this with activerecord?
> I read about transactions, but as i understand a transaction acts on a
> single connection to the database.

This would be a single DB connection, so it seems like a good candidate 
for a transaction.  What's the problem with doing that?

Best,
--
Marnen Laibow-Koser
http://www.marnen.org
[email protected]
-- 
Posted via http://www.ruby-forum.com/.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to