Class: TagsController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/tags_controller.rb

Instance Method Summary collapse

Instance Method Details

#indexObject



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'app/controllers/tags_controller.rb', line 4

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