When I increment some integer column using increment_counter and passing some record id and then try to get the first record using Model.first, this return the record id plus 1.
Something like this:
Model.increment_counter :field, id
Model.first
It returns not the
Model.find(1)
but
Model.find(id+1)
Is that some particular issue of postgreSQL?
Model.first will use the default sorting of your database (which is not necessarily an id).
Try this instead:
Model.order("id").first
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With