def set_relations(context, relation)
      @contexts ||= {}
      @contexts[relation] ||= []
      @media_relation_set ||= []
      if @contexts[relation].include?(context)
        raise Exception.new("You should NOT use same context identifier for several has_one or has_many relation to media")
      end
      @contexts[relation] << context
      return if @media_relation_set.include? self
      has_many :media, :through => :media_links, :dependent => :destroy

      @media_relation_set << self
    end
def set_relations(context, relation)
      @contexts ||= {}
      @contexts[relation] ||= []
      @media_relation_set ||= []
      if @contexts[relation].include?(context)
        raise Exception.new("You should NOT use same context identifier for several has_one or has_many relation to media")
      end
      @contexts[relation] << context
      return if @media_relation_set.include? self
      has_many :media, :through => :media_links, :dependent => :destroy

      @media_relation_set << self
    end
set_relations
 add relation on medium if not exists
 Also check if a class has a duplicate context

 @param [String] context
 @param [String] relation type, one of :has_many, :has_one