Count all posts in this category and all sub-categories – ActiveRecord – Mysql
There are two tables in my project: posts and post_categories. Each post in the posts table has a post_category_id relating to post_categories.id as fk, and each entry in post_categories has a parent_id - self-referencing post_categories.id. On the website, the post…