Reputation: 1
I have a list of items, those items have some attributes one of which is an array list. The array list may be empty or not.
How do i retrieve the items from the list that their array list is not empty
Upvotes: 0
Views: 41
Reputation: 44581
You can use select
together with present?
(or reject
/blank?
):
items = items.select{|x| x.array_attribute.present?}
Upvotes: 1