3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
# File 'lib/resourcify/controller/actions/index.rb', line 3
def index
authorize _RC.new
@records = _RC.includes(belongs_tos)
if @records.respond_to? "filter_by"
@records = @records.filter_by(params.except(:controller, :action, :page, :size))
end
@records = policy_scope(@records)
response.['_meta_total'] = @records.count.to_s
page = params[:page] || 1
size = params[:size] || 20
@records = @records.offset((page.to_i - 1) * size.to_i).limit(size)
render json: @records
end
|