Sha256: 399a7145d8b1162506e1a66d1fb70b3e4b25be45c26967300a692aeee8a24d6c

Contents?: true

Size: 561 Bytes

Versions: 97

Compression:

Stored size: 561 Bytes

Contents

class Admin::TagsController < Admin::BaseController
  respond_to :json

  def index
    term = params[:term]
    context = params[:context] || "tags"
    
    @tag_names = if(term && term.size >= 3)
      condition = ActsAsTaggableOn::Tag.arel_table[:name].matches("%#{term}%")
      tags = ActsAsTaggableOn::Tag.joins("JOIN taggings on taggings.tag_id = tags.id").where(condition)
      
      if context
        tags = tags.where("taggings.context" => context)
      end
      
      tags.pluck(:name)
    end || []

    render :json => @tag_names
  end
 
end

Version data entries

97 entries across 97 versions & 1 rubygems

Version Path
fullstack-cms-0.4.6 app/controllers/admin/tags_controller.rb
fullstack-cms-0.4.5 app/controllers/admin/tags_controller.rb
fullstack-cms-0.4.4 app/controllers/admin/tags_controller.rb
fullstack-cms-0.3.8.fix app/controllers/admin/tags_controller.rb
fullstack-cms-0.2.32.fix app/controllers/admin/tags_controller.rb
fullstack-cms-0.4.3 app/controllers/admin/tags_controller.rb
fullstack-cms-0.4.2 app/controllers/admin/tags_controller.rb
fullstack-cms-0.4.1 app/controllers/admin/tags_controller.rb
fullstack-cms-0.3.39 app/controllers/admin/tags_controller.rb
fullstack-cms-0.3.38 app/controllers/admin/tags_controller.rb
fullstack-cms-0.3.37 app/controllers/admin/tags_controller.rb
fullstack-cms-0.3.36 app/controllers/admin/tags_controller.rb
fullstack-cms-0.3.35 app/controllers/admin/tags_controller.rb
fullstack-cms-0.3.34 app/controllers/admin/tags_controller.rb
fullstack-cms-0.3.33 app/controllers/admin/tags_controller.rb
fullstack-cms-0.3.32 app/controllers/admin/tags_controller.rb
fullstack-cms-0.3.31 app/controllers/admin/tags_controller.rb
fullstack-cms-0.3.30 app/controllers/admin/tags_controller.rb
fullstack-cms-0.3.29 app/controllers/admin/tags_controller.rb
fullstack-cms-0.3.28 app/controllers/admin/tags_controller.rb