I have the following parent - child models.
belongs_to :parent, :foreign_key => “parent_id”
Now, in my list of parents, the user can click a link to see the children for a parent. What I’d want to do is to show whether a parent has any children on the parent list page, without the user having to click on the link to find out.
My current query to populate the table is as follows:
@parents = Parent.find(:all, :order => “name”)
Can this query be modified to get the number of children as well? Or, return true if the parent has at least one child?