Wednesday, November 11, 2009

Ruby on Rails : Array : Remove duplicate item

In views.rhtml
<% 
x = 0
arr_type = Array.new
@articles = Article.find(:all)
for article in @articles
arr_type[x] = article.type
x += 1
end
@type = arr_type.uniq*", "

# Output
@articles = research, research, product, product, research, calendar
@type = research, product, calendar
%>

1 comment: