Update query.all to query.to_a to get array