volontariat/voluntary

View on GitHub
app/controllers/voluntary/api/v1/argument_topics_controller.rb

Summary

Maintainability
A
0 mins
Test Coverage
module Voluntary
  module Api
    module V1
      class ArgumentTopicsController < ActionController::Base
        include Voluntary::V1::BaseController
       
        respond_to :json
        
        def autocomplete
          render json: (
            ArgumentTopic.order(:name).where("name LIKE ?", "%#{params[:term]}%").
            map{|t| { id: t.id, value: t.name.truncate(50) }}
          ), root: false
        end
      end
    end
  end
end