Skip to content

Instantly share code, notes, and snippets.

@aalvesjr
Created January 28, 2013 02:23
Show Gist options
  • Select an option

  • Save aalvesjr/4652406 to your computer and use it in GitHub Desktop.

Select an option

Save aalvesjr/4652406 to your computer and use it in GitHub Desktop.
Categorias com produtos, usando :all
class Category < ActiveRecord::Base
def self.with_products
self.all.select {|category| category.products.any? }
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment