Class: TagsController

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

Constant Summary

Constants inherited from ApplicationController

ApplicationController::ALLOWABLE_CONFIGS

Instance Method Summary collapse

Instance Method Details

#indexObject



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

def index
  respond_to do |format|
    format.json do
      tags = begin
        if params[:search]
          ActsAsTaggableOn::Tag.distinct.where('name LIKE ?', "%#{params[:search]}%").pluck(:name)
        else
          ActsAsTaggableOn::Tag.distinct.pluck(:name)
        end
      end

      render json: tags
    end
  end
end