pedro
pedro

Reputation: 1

Retrieve items that do not have an empty array list

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

Answers (1)

potashin
potashin

Reputation: 44581

You can use select together with present? (or reject/blank?):

items = items.select{|x| x.array_attribute.present?}

Upvotes: 1

Related Questions