Increment another table on vote insertion

I have a table votes and another table ratings, when a user inserts a vote it should automatically increment the rating,

I am using postgresql triggers to do that, but I’m looking for a better way maybe using associations or another more efficient solution

prepare_changes/2 might suit your needs. The example in the docs seems to be pretty much your use case.


that is great, thanks