I have an array of id's ["2", "3", "2", "3"] for example.
I'm attempting to iterate through these array elements.
@car = car.first @driver = @car.drivers.first service_ids = ["2", "3", "2", "3"] service_ids.each do |service_id| arr = [] results = @driver.services.find_by(id: service_id) arr << results end arr only returns a single record, likely the last record found.
How do you accomplish this? Is there a rails method that does something like this?
Thanks.