Sha256: 45fa65bf15d26a7cb162cf91557999f1b4ab5ec2d5d76a2d422088dd7fe5370b

Contents?: true

Size: 650 Bytes

Versions: 25

Compression:

Stored size: 650 Bytes

Contents

class TagsController < ApplicationController
  before_filter :authenticate_user!
  
  def index
    @tags =
      case params[:mode]
      when "popular"
        most_popular
      else
        match_tag
      end

    if @tags.blank? && params[:q].present?
      @tags = [ ActsAsTaggableOn::Tag.new(name: params[:q]) ]
    end

    respond_to do |format|
      format.json {
        render json: @tags
      }
    end
  end

  private

  def match_tag
    ActsAsTaggableOn::Tag.where('name LIKE ?',"%#{ params[:q] }%").page(params[:page])
  end

  def most_popular
    ActivityObject.tag_counts(:order => "count desc").page(params[:page])
  end
end

Version data entries

25 entries across 25 versions & 2 rubygems

Version Path
social_stream-2.2.2 base/app/controllers/tags_controller.rb
social_stream-base-2.2.2 app/controllers/tags_controller.rb
social_stream-2.2.1 base/app/controllers/tags_controller.rb
social_stream-base-2.2.1 app/controllers/tags_controller.rb
social_stream-2.2.0 base/app/controllers/tags_controller.rb
social_stream-base-2.2.0 app/controllers/tags_controller.rb
social_stream-2.1.1 base/app/controllers/tags_controller.rb
social_stream-2.1.0 base/app/controllers/tags_controller.rb
social_stream-base-2.1.0 app/controllers/tags_controller.rb
social_stream-2.0.4 base/app/controllers/tags_controller.rb
social_stream-base-2.0.4 app/controllers/tags_controller.rb
social_stream-2.0.3 base/app/controllers/tags_controller.rb
social_stream-base-2.0.3 app/controllers/tags_controller.rb
social_stream-2.0.2 base/app/controllers/tags_controller.rb
social_stream-base-2.0.2 app/controllers/tags_controller.rb
social_stream-2.0.1 base/app/controllers/tags_controller.rb
social_stream-base-2.0.1 app/controllers/tags_controller.rb
social_stream-2.0.0 base/app/controllers/tags_controller.rb
social_stream-base-2.0.0 app/controllers/tags_controller.rb
social_stream-2.0.0.beta3 base/app/controllers/tags_controller.rb