data_tables 0.1.16 → 0.1.17

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/data_tables.gemspec +1 -1
  2. data/lib/data_tables.rb +9 -2
  3. metadata +2 -2
data/data_tables.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = 'data_tables'
5
- s.version = '0.1.16'
5
+ s.version = '0.1.17'
6
6
  s.date = Time.now.strftime("%Y-%m-%d")
7
7
  s.summary = "Rails friendly interface into DataTables"
8
8
  s.description = "DataTables for Rails"
data/lib/data_tables.rb CHANGED
@@ -46,6 +46,7 @@ module DataTablesController
46
46
  named_scope_args = options[:named_scope_args]
47
47
  except = options[:except] || []
48
48
  es_block = options[:es_block]
49
+ order_sort = options[:order_sort]
49
50
 
50
51
  #
51
52
  # ------- Ohm ----------- #
@@ -304,14 +305,20 @@ module DataTablesController
304
305
  end
305
306
  sort_column = params[:iSortCol_0].to_i
306
307
  current_page = (params[:iDisplayStart].to_i/params[:iDisplayLength].to_i rescue 0)+1
308
+ order = if order_sort.respond_to?(:call)
309
+ order_sort.call(columns[sort_column][:name], params[:sSortDir_0])
310
+ else
311
+ "#{columns[sort_column][:name]} #{params[:sSortDir_0]}"
312
+ end
313
+
307
314
  if named_scope
308
315
  objects = modelCls.send(named_scope, *args).paginate(:page => current_page,
309
- :order => "#{columns[sort_column][:name]} #{params[:sSortDir_0]}",
316
+ :order => order,
310
317
  :conditions => conditions.join(" AND "),
311
318
  :per_page => params[:iDisplayLength])
312
319
  else
313
320
  objects = modelCls.paginate(:page => current_page,
314
- :order => "#{columns[sort_column][:name]} #{params[:sSortDir_0]}",
321
+ :order => order,
315
322
  :conditions => conditions.join(" AND "),
316
323
  :per_page => params[:iDisplayLength])
317
324
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: data_tables
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.1.16
5
+ version: 0.1.17
6
6
  platform: ruby
7
7
  authors:
8
8
  - Duane Compton
@@ -13,7 +13,7 @@ authors:
13
13
  autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
- date: 2013-09-12 00:00:00.000000000 Z
16
+ date: 2013-10-03 00:00:00.000000000 Z
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
19
19
  type: :development