When I worked on Best Tech Videos with Alexey Kovyrin, we faced a problem of filtering videos by category with selecting posts categories in the same query. It was easy to solve the problem, but there is one query optimization trick exists.
Using sub-queries to avoid multiple DB requests in Rails
Posted by Dmytro Shteflyuk on under Ruby & Rails