Sha256: b9f709c7d683b3f49abd46b6b934ebaede1add3b3a7b6afbccca1f4402fcff84

Contents?: true

Size: 745 Bytes

Versions: 28

Compression:

Stored size: 745 Bytes

Contents

module Para
  module Admin
    class SearchController < ApplicationController
      include Para::Helpers::ResourceName

      def index
        # Parse ids that are provided as string into array
        if params[:q] && params[:q][:id_in].is_a?(String)
          params[:q][:id_in] = params[:q][:id_in].split(',')
        end

        model = params[:model_name].constantize
        @results = model.ransack(params[:q]).result
        @results = @results.limit(params[:limit]) if params[:limit]

        case params[:mode]
        when "selectize"
          render json: @results.map { |res|
            { text: resource_name(res), value: res.id }
          }
        else
          render layout: false
        end
      end
    end
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
para-0.8.12 app/controllers/para/admin/search_controller.rb
para-0.8.11 app/controllers/para/admin/search_controller.rb
para-0.8.10 app/controllers/para/admin/search_controller.rb
para-0.8.9 app/controllers/para/admin/search_controller.rb
para-0.8.8 app/controllers/para/admin/search_controller.rb
para-0.8.7 app/controllers/para/admin/search_controller.rb
para-0.8.5 app/controllers/para/admin/search_controller.rb
para-0.8.3.3 app/controllers/para/admin/search_controller.rb