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