File tree Expand file tree Collapse file tree 1 file changed +21
-1
lines changed
lib/ajax-datatables-rails Expand file tree Collapse file tree 1 file changed +21
-1
lines changed Original file line number Diff line number Diff line change 3
3
module AjaxDatatablesRails
4
4
class Base
5
5
6
- class_attribute :db_adapter , default : ::ActiveRecord ::Base . configurations . configs_for ( env_name : Rails . env ) . first . adapter . downcase . to_sym
6
+ class << self
7
+ def rails_52?
8
+ Rails . gem_version >= Gem ::Version . new ( '5.2' ) && Rails . gem_version <= Gem ::Version . new ( '6.0' )
9
+ end
10
+
11
+ def rails_60?
12
+ Rails . gem_version >= Gem ::Version . new ( '6.0' ) && Rails . gem_version <= Gem ::Version . new ( '6.1' )
13
+ end
14
+
15
+ def default_db_adapter
16
+ if rails_52?
17
+ ::ActiveRecord ::Base . configurations . dig ( Rails . env , 'adapter' ) . downcase . to_sym
18
+ elsif rails_60?
19
+ ::ActiveRecord ::Base . configurations . configs_for ( env_name : Rails . env ) . first . config [ 'adapter' ] . downcase . to_sym
20
+ else
21
+ ::ActiveRecord ::Base . configurations . configs_for ( env_name : Rails . env ) . first . adapter . downcase . to_sym
22
+ end
23
+ end
24
+ end
25
+
26
+ class_attribute :db_adapter , default : default_db_adapter
7
27
class_attribute :nulls_last , default : false
8
28
9
29
attr_reader :params , :options , :datatable
You can’t perform that action at this time.
0 commit comments