2012-11-23 5 views

답변

3

내가 이런 식으로 할 거라고 :

hostgroups <%= (n.run_list.roles.to_a & another_a).join(",") %> 
0

어떻게 배열의 select 메서드를 사용하는 방법에 대한?

여기서 "허용 된"단어로 other_collection을 가정합니다.

hostgroups <%= n.run_list.roles.to_a.select {|elem| other_collection.include? elem}.join(",") %> 

도움이 될지 알려주세요.

편집 루비의 배열에 대한 설명서에 링크 : http://www.ruby-doc.org/core-1.9.3/Array.html

관련 문제