I want to update the number_of_votes in the users table based on the poll_records table. In rails, it looks like
User.all.each do |user|
user.number_of_votes = user.poll_records.where("poll_record_type = 3").size
user.save
end
I am new to PostgreSQL. How can I update users this way?
Could be like this:
I wouldn’t use
"User"(reserved word) or mixed case identifiers as table name. It forces double quoting.