Created
September 21, 2023 17:11
-
-
Save cjavdev/7877e92cb2aed3a2b6c26675893204f3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ActiveRecord::Base.connection.execute(<<-SQL) | |
UPDATE projects | |
SET comments_count = ( | |
SELECT COUNT(*) | |
FROM comments | |
WHERE comments.commentable_id = projects.id | |
AND comments.commentable_type = 'Project' | |
) | |
SQL |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment