I am using Model.increment_counter(:c, 11)
in order to avoid race conditions when incrementing a column (See related: How do I consistently increase a counter cache column?)
I notice however that for the following code:
@order = Order.find(11)
p @order.c # This prints 4
Order.increment_counter(:c, 11)
p @order.c # This still prints 4
@order.reload
p @order.c # This prints 5
Why is it necessary to reload the object after doing the update? Why does AR not show that change directly?