Sha256: e7585f1452f365fa82b38d145eb0528e217f05136671e5ec3ab83396a5dd0ce4

Contents?: true

Size: 453 Bytes

Versions: 5

Compression:

Stored size: 453 Bytes

Contents

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

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
voluntary-0.7.1 app/controllers/voluntary/api/v1/argument_topics_controller.rb
voluntary-0.7.0 app/controllers/voluntary/api/v1/argument_topics_controller.rb
voluntary-0.6.0 app/controllers/voluntary/api/v1/argument_topics_controller.rb
voluntary-0.5.2 app/controllers/voluntary/api/v1/argument_topics_controller.rb
voluntary-0.5.1 app/controllers/voluntary/api/v1/argument_topics_controller.rb