Module: ScopeDo::ClassMethods

Defined in:
lib/scope_do/has_children.rb

Instance Method Summary collapse

Instance Method Details

#has_children(target) ⇒ Object



45
46
47
48
49
50
51
52
53
# File 'lib/scope_do/has_children.rb', line 45

def has_children(target)
  association = reflections[target]
  builder = QueryBuilder.new(self, association)
  qs = builder.has_children_query_parts

  named_scope "has_#{target}", proc{|*n|
    {:conditions => QueryBuilder.has_children_condition(n.shift, qs)}
  }
end