Rails querying an associated models scope
问题 I am struggling to find a suitable solution for what should be a simple task. Essentially I have a category model which has many posts . The post belongs to the category . I am displaying categories as part of a search form as well as a number of other places and do not want to display categories that have no associated posts. That seems kind of pointless. I managed to solve this problem by adding the following method to my category model. # Check if Category has associated results def self