4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
# File 'lib/azahara_schema/controller_additions.rb', line 4
def azahara_schema_index(**options, &block)
azahara_schema_for_index(**options, &block)
respond_to do |format|
format.html
format.json {
json_result = {}
if params['_type'] == 'query'
json_result[:results] = @resource_schema.entities.collect do |o|
{id: o.id, text: o.to_s}
end
elsif params['_type'] == 'count'
json_result = {count: @resource_schema.entity_count}
else
json_result = {entities: @resource_schema, count: @resource_schema.entity_count}
end
render json: json_result
}
format.csv {
require 'csv'
['Content-Disposition'] = "attachment; filename=\"#{@resource_schema.model.model_name.human(count: :other)}.csv\""
['Content-Type'] ||= 'text/csv'
render @resource_schema.csv_template, layout: false
}
end
end
|