Module: Redmineup::Patches::AutoCompletesControllerPatch

Defined in:
lib/redmineup/patches/auto_completes_controller_patch.rb

Constant Summary collapse

DEFAULT_TAGS_LIMIT =
10

Instance Method Summary collapse

Instance Method Details

#taggable_tagsObject



6
7
8
9
10
11
12
# File 'lib/redmineup/patches/auto_completes_controller_patch.rb', line 6

def taggable_tags

  limit = params.delete(:limit) || DEFAULT_TAGS_LIMIT
  klass = Object.const_get(params[:taggable_type].camelcase) if params[:taggable_type].present?
  tags = klass && klass.available_tags(params.merge(limit: limit)) || Redmineup::ActsAsTaggable::Tag.limit(limit)
  render json: tags.map { |tag| { id: tag.name, text: tag.name } }
end