So this below has always worked for me, but now I need to remove some of the items to get true cost and true sale price. I need to remove all items from this sum that has a parent_id of nil. How can I do this without making another sql query?
def total_price
# convert to array so it doesn't try to do sum on database directly
items.to_a.sum(&:full_price)
end
You can do