Skip to content

Commit 9b6f949

Browse files
committed
Extract method
1 parent c20adb0 commit 9b6f949

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

lib/ajax-datatables-rails/base.rb

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,11 @@ def additional_data
7373

7474
# JSON structure sent to jQuery DataTables
7575
def as_json(*)
76-
draw_resp = (params[:draw].present?) ? { draw: params[:draw].to_i } : { }
77-
7876
{
7977
recordsTotal: records_total_count,
8078
recordsFiltered: records_filtered_count,
8179
data: sanitize_data(data),
82-
}.merge(draw_resp).merge(additional_data)
80+
}.merge(draw_id).merge(additional_data)
8381
end
8482

8583
# User helper methods
@@ -154,6 +152,11 @@ def global_search_delimiter
154152
GLOBAL_SEARCH_DELIMITER
155153
end
156154

155+
# See: https://datatables.net/manual/server-side#Returned-data
156+
def draw_id
157+
params[:draw].present? ? { draw: params[:draw].to_i } : {}
158+
end
159+
157160
def raw_records_error_text
158161
<<-ERROR
159162

0 commit comments

Comments
 (0)