I have a Coach
Model which:
has_many :qualifications
I want to find all coaches whose some attribute_id
is nil
and they have some qualifications
. Something which is like.
def requirement
legal_coaches = []
coaches = find_all_by_attribute_id(nil)
coaches.each do |coach|
legal_coaches << coach if coach.qualifications.any?
end
legal_coaches
end
Is there a way to get all such records in one line ?