On 19 August 2010 21:18, Philip Hallstrom <[email protected]> wrote: > Don't use increment. It won't do what you want since it's only incrementing > the value of the object and then saving it. Not updating the value in the > database.
What is "saving" if not updating in the database? > You want to use increment_counter which calls update_counters which does this > in the database: What is the result of your "u" "u1" console experiment when you use increment_counter rather than increment? As far as I can see it will be the same - you've got two copies of an object loaded, and you update one, without reloading the other; of course that can lead to race conditions and stale data. -- 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.

