DEV Community

loading...
JetRockets

Rails: increment counter cache and return value

Igor Alexandrov
・1 min read

What will you do if you have to in/decrement counter cache column and get it actual value via single query?. Learn how to hack ActiveRecord to do this in easy and pretty cool way.

http://jetrockets.pro/blog/rails-increment-counter-cache-and-return-value

Discussion (4)

Collapse
dsalahutdinov profile image
Dmitry Salahutdinov

Hi Igor, do you consider to create simple gem and make the common patch ?

Collapse
igor_alexandrov profile image
Igor Alexandrov Author
Collapse
igor_alexandrov profile image
Igor Alexandrov Author

I will update description and add specs later.

Collapse
igor_alexandrov profile image
Igor Alexandrov Author

Sure, give me a couple of days.