I have a collection of objects with certain attributes. I also have a CONSTANT array of ids.
I want to return the whole objects who have an id that exists in the constant array.
This is what I have so far, but it just returns true or false for each, I need it to return an array of all the objects:
some_object_attributes.collect { |attr| (Constant::SOME_IDS.include? attr.object.object_type_id)}
How can I return every attr.object which has an ID in the constant array?
Setinstead of an array might improve the performance a lot.scope :in_constant_array, -> { where( object_type_id: Constant::SOME_IDS)}then you can leverage SQL to do the lifting rather than in mem