I think the problem is, that each does not return all links as an array or concatenated string, but instead an iterator object or only the last link. You can try to create an array of links with the map method and then concatenate them with join(', ').