PERF: memoize to avoid N+1 query in category page

This commit is contained in:
Sam 2015-10-02 12:35:47 +10:00
parent 55c0f6a20c
commit 6246dd0aa2

View file

@ -382,7 +382,8 @@ SQL
end
def has_children?
id && Category.where(parent_category_id: id).exists?
@has_children ||= (id && Category.where(parent_category_id: id).exists?) ? :true : :false
@has_children == :true
end
def uncategorized?