Skip to content

Instantly share code, notes, and snippets.

@chollier
Created September 24, 2010 15:10
Show Gist options
  • Save chollier/595525 to your computer and use it in GitHub Desktop.
Save chollier/595525 to your computer and use it in GitHub Desktop.
def subproduct?
!self.parent.blank?
end
def self.not_sub
returning [] do |value|
Product.each do |x|
if !x.subproduct?
value << x
end
end
end
end
@chollier
Copy link
Author

En SQL c'est mieux en effet :

scope :not_sub, lambda {
joins("left join product_joins on products.id = product_joins.sub_product_id").where('product_joins.product_id' => nil)
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment