Ruby on Rails Friday, June 8, 2012

This is how children is defined[1]:

has_many :children, class_name: name,
        foreign_key: configuration[:foreign_key],
        order: configuration[:order],
        dependent: configuration[:dependent],
        inverse_of: :parent

If you do: root.children.where(:type => yourtype) it should just work.


-- 
Oscar Del Ben
Sent with Sparrow

On Friday, June 8, 2012 at 7:18 AM, ibrahim hassan wrote:

Hello Experts,
I have a tree of categories in this category object there is a property
called type.
the root categories have no type but the children have. so how I can get
all the roots with filled in children that have category type = 'B' for
instance.
I tried to run Category.roots then delete children With a category not
equal to 'B' but this causes a major performance problems.

how to call roots with filter children?


best regards
Ibrahim

--

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

No comments:

Post a Comment