Uniq by object attribute in Ruby June 7, 2023 by Tarik Use Array#uniq with a block: @photos = @photos.uniq { |p| p.album_id }