6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
# File 'app/controllers/para/admin/search_controller.rb', line 6
def index
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
|