app/controllers/tags_controller.rb
#
# Get a set of the instances with the given tag
#
Get a set of the instances with the given tag
Get a set of the instances with the given tag
def list
    context = params[:context] 
    className = params[:class] 
    exclude = params[:exclude]
    @results = nil
    op = exclude ? :match_all : :any
    query = ''
    if context.class == HashWithIndifferentAccess
      context.each do |key, ctx|
        query += ".tagged_with('" + params[:tag][key] + "', :on => '" + ctx + "', '+op+' => true)"
      end
    end
    if isok(className)
      cl = eval(className) 
      page = params[:page] ? params[:page].to_i : 1
      pagesize = params[:pagesize] ? params[:pagesize].to_i : 10
      if query.empty?
        @results = Person.tagged_with(params[:tag], :on => context, op => true).by_last_name.paginate(:page => page, :per_page => pagesize)
      else
        @results = eval "Person" + query + ".by_last_name.paginate(:page => page, :per_page => pagesize)"
      end
    end
    respond_to do |format|
      format.html { render :layout => 'content' } 
      format.xml  { render :xml => @results }
    end
  end
def list context = params [ :context ] className = params [ :class ] exclude = params [ :exclude ] @results = nil op = exclude ? :match_all : :any query = '' if context . class == HashWithIndifferentAccess context . each do | key , ctx | query += ".tagged_with('" + params [ :tag ] [ key ] + "', :on => '" + ctx + "', '+op+' => true)" end end if isok ( className ) cl = eval ( className ) page = params [ :page ] ? params [ :page ] . to_i : 1 pagesize = params [ :pagesize ] ? params [ :pagesize ] . to_i : 10 if query . empty? @results = Person . tagged_with ( params [ :tag ] , :on => context , op => true ) . by_last_name . paginate ( :page => page , :per_page => pagesize ) else @results = eval "Person" + query + ".by_last_name.paginate(:page => page, :per_page => pagesize)" end end respond_to do | format | format . html { render :layout => 'content' } format . xml { render :xml => @results } end end
Get a set of the instances with the given tag
Get a set of the instances with the given tag
# For each of the possible contexts get the tags... # context # class # get the instance of the class # Allowed operations are any or match_all, if exclude has been passed then we assume an exact match... # 3. Then pass this along to the view # list.html.erb