Uniq by object attribute in Ruby

Use Array#uniq with a block:

@photos = @photos.uniq { |p| p.album_id }

Leave a Comment