Skip to content

Instantly share code, notes, and snippets.

@paterson
Created May 6, 2014 16:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save paterson/74e2f00d210383091b30 to your computer and use it in GitHub Desktop.
Save paterson/74e2f00d210383091b30 to your computer and use it in GitHub Desktop.
class Parent < ActiveRecord::Base
def has_grandchildren
childs.includes(:grandchilds).group("childs.id").having("count(grandchilds.id) < 0")
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment