You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: multi_tag.rb
    path of file: ./repos/gallerist/lib/gallerist
    
    the code of the file until where you have to start completion: # This code is free software; you can redistribute it and/or modify it under
# the terms of the new BSD License.
#
# Copyright (c) 2015-2016, 
    
  def photos
    photos = @library.photos.distinct.joins(:tag_photos)
            .where(RKKeywordForVersion: { keywordId: @tags.map(&:id) })

    if @intersect
      unique_tags = Gallerist::TagPhoto.select(:modelId)
              .group(:keywordId, :versionId)
      photos = photos.where(RKKeywordForVersion: { modelId: unique_tags })
              .group(:versionId)
              .having('count(versionId) = ?', @tags.size)
    end