ransack 2.3.0 → 2.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +18 -20
  3. data/CHANGELOG.md +9 -1
  4. data/Gemfile +17 -5
  5. data/README.md +25 -31
  6. data/lib/ransack.rb +1 -2
  7. data/lib/ransack/adapters/active_record/context.rb +11 -78
  8. data/lib/ransack/adapters/active_record/ransack/constants.rb +12 -0
  9. data/lib/ransack/adapters/active_record/ransack/context.rb +1 -6
  10. data/lib/ransack/adapters/active_record/ransack/nodes/condition.rb +1 -1
  11. data/lib/ransack/constants.rb +0 -3
  12. data/lib/ransack/helpers/form_builder.rb +5 -11
  13. data/lib/ransack/locale/sk.yml +70 -0
  14. data/lib/ransack/nodes/condition.rb +8 -0
  15. data/lib/ransack/predicate.rb +2 -1
  16. data/lib/ransack/version.rb +1 -1
  17. data/polyamorous/lib/polyamorous.rb +2 -7
  18. data/polyamorous/lib/polyamorous/{activerecord_5.2.1_ruby_2 → activerecord_5.2_ruby_2}/join_association.rb +0 -2
  19. data/polyamorous/lib/polyamorous/{activerecord_5.2.1_ruby_2 → activerecord_5.2_ruby_2}/join_dependency.rb +0 -2
  20. data/polyamorous/lib/polyamorous/{activerecord_5.2.0_ruby_2 → activerecord_5.2_ruby_2}/reflection.rb +0 -0
  21. data/polyamorous/lib/polyamorous/activerecord_6.0_ruby_2/join_association.rb +1 -1
  22. data/polyamorous/lib/polyamorous/activerecord_6.0_ruby_2/reflection.rb +1 -1
  23. data/polyamorous/polyamorous.gemspec +1 -9
  24. data/ransack.gemspec +3 -12
  25. data/spec/helpers/polyamorous_helper.rb +1 -10
  26. data/spec/ransack/predicate_spec.rb +38 -0
  27. data/spec/ransack/search_spec.rb +1 -8
  28. data/spec/spec_helper.rb +2 -0
  29. data/spec/support/schema.rb +3 -1
  30. metadata +14 -146
  31. data/polyamorous/lib/polyamorous/activerecord_5.0_ruby_2/join_association.rb +0 -2
  32. data/polyamorous/lib/polyamorous/activerecord_5.0_ruby_2/join_dependency.rb +0 -2
  33. data/polyamorous/lib/polyamorous/activerecord_5.1_ruby_2/join_association.rb +0 -31
  34. data/polyamorous/lib/polyamorous/activerecord_5.1_ruby_2/join_dependency.rb +0 -112
  35. data/polyamorous/lib/polyamorous/activerecord_5.2.0_ruby_2/join_association.rb +0 -31
  36. data/polyamorous/lib/polyamorous/activerecord_5.2.0_ruby_2/join_dependency.rb +0 -112
  37. data/polyamorous/lib/polyamorous/activerecord_5.2.1_ruby_2/reflection.rb +0 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: be6fda6bbab697d2f125847b2761df81991190d8d9799b5480ac2044441978a0
4
- data.tar.gz: 9f39f157e148aa2c4638b8e9c7ab5a8b14221f315e880c04e5f76f3db2a1b473
3
+ metadata.gz: c260460e29557bfaf458660fb8a773527dd30041a607744dc7bf50932686ce17
4
+ data.tar.gz: 9d464cc20039e59bda380d476795248247365ef3d85ef27b09f5454c64c7b657
5
5
  SHA512:
6
- metadata.gz: 2fc2082431692f609ddb39171876ade4e1eb4ce715ad917f196db6714a1f55872852c61dec20a047bf48b31f9cab812417fb94f1e9ae9786771320cbd6bc54a4
7
- data.tar.gz: ea1ed1a393fe699432f7012facf66e01b48725d73eb7c8956f17435b447ce745fb65c235425cc28079ba1b1c74d64ba758710f25793f738ea92a49f5409abb68
6
+ metadata.gz: 5707108e7e4f6644fbaf6562aa81a11c7e1572b53adc3843b5ad40d0b31d1c21b4c47005a6171323f7665ccc454a48cf3320b8a1d4a3c82a0117887ad0ba0467
7
+ data.tar.gz: fcebb926b620c49214f04350d233d8250a5027eb71fa65fb07e7b3751c296ca7871c20ac54a3edfa2f218afb341565517fb97710ba64d13451b413047ac4fc60
@@ -1,9 +1,7 @@
1
1
  language: ruby
2
2
 
3
- sudo: false
4
-
5
3
  rvm:
6
- - 2.6.0
4
+ - 2.6.5
7
5
 
8
6
  services:
9
7
  - mysql
@@ -21,27 +19,27 @@ env:
21
19
  - RAILS=5-2-stable DB=mysql
22
20
  - RAILS=5-2-stable DB=postgres
23
21
 
24
- - RAILS=v5.2.1 DB=sqlite3
25
- - RAILS=v5.2.1 DB=mysql
26
- - RAILS=v5.2.1 DB=postgres
27
-
28
- - RAILS=v5.2.0 DB=sqlite3
29
- - RAILS=v5.2.0 DB=mysql
30
- - RAILS=v5.2.0 DB=postgres
31
-
32
- - RAILS=5-1-stable DB=sqlite3
33
- - RAILS=5-1-stable DB=mysql
34
- - RAILS=5-1-stable DB=postgres
22
+ - RAILS=v5.2.3 DB=sqlite3
23
+ - RAILS=v5.2.3 DB=mysql
24
+ - RAILS=v5.2.3 DB=postgres
35
25
 
36
26
  matrix:
37
27
  allow_failures:
38
- - env: RAILS=5-2-stable DB=sqlite3
39
- - env: RAILS=5-2-stable DB=mysql
40
- - env: RAILS=5-2-stable DB=postgres
28
+ - env: RAILS=6-0-stable DB=sqlite3
29
+ - env: RAILS=6-0-stable DB=mysql
30
+ - env: RAILS=6-0-stable DB=postgres
31
+
41
32
  before_script:
42
- - mysql -e 'create database ransack collate utf8_general_ci;'
43
- - mysql -e 'use ransack;show variables like "%character%";show variables like "%collation%";'
44
- - psql -c 'create database ransack;' -U postgres
33
+ - if [ "$DB" = "mysql" ];
34
+ then
35
+ mysql -e 'create database ransack collate utf8_general_ci;';
36
+ mysql -e 'use ransack;show variables like "%character%";show variables like "%collation%";';
37
+ fi
38
+
39
+ - if [ "$DB" = "postgres" ];
40
+ then
41
+ psql -c 'create database ransack;' -U postgres;
42
+ fi
45
43
 
46
44
  addons:
47
45
  code_climate:
@@ -1,6 +1,14 @@
1
1
  # Change Log
2
2
 
3
- ## Unreleased
3
+ ## 2.3.1 - 2010-01-01
4
+
5
+ * Drop support for Active Record 5.0, 5.1, and 5.2.0.
6
+ PR [#1073](https://github.com/activerecord-hackery/ransack/pull/1073)
7
+
8
+ * Drop support for rubies under 2.3.
9
+ PR [#1070](https://github.com/activerecord-hackery/ransack/pull/1070)
10
+
11
+ ... and others
4
12
 
5
13
  ## 2.3.0 - 2019-08-18
6
14
 
data/Gemfile CHANGED
@@ -5,16 +5,28 @@ gem 'rake'
5
5
 
6
6
  rails = ENV['RAILS'] || '6-0-stable'
7
7
 
8
- gem 'pry'
8
+ rails_version = case rails
9
+ when /\// # A path
10
+ File.read(File.join(rails, "RAILS_VERSION"))
11
+ when /^v/ # A tagged version
12
+ rails.gsub(/^v/, '')
13
+ else
14
+ rails
15
+ end
9
16
 
10
- # Provide timezone information on Windows
11
- gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw]
17
+ gem 'faker', '~> 0.9.5'
18
+ gem 'sqlite3', ::Gem::Version.new(rails_version) >= ::Gem::Version.new('6-0-stable') ? '~> 1.4.1' : '~> 1.3.3'
19
+ gem 'pg', '~> 1.0'
20
+ gem 'pry', '0.10'
21
+ gem 'byebug'
12
22
 
13
23
  case rails
14
24
  when /\// # A path
15
25
  gem 'activesupport', path: "#{rails}/activesupport"
26
+ gem 'activemodel', path: "#{rails}/activemodel"
16
27
  gem 'activerecord', path: "#{rails}/activerecord", require: false
17
28
  gem 'actionpack', path: "#{rails}/actionpack"
29
+ gem 'actionview', path: "#{rails}/actionview"
18
30
  when /^v/ # A tagged version
19
31
  git 'https://github.com/rails/rails.git', :tag => rails do
20
32
  gem 'activesupport'
@@ -33,7 +45,7 @@ end
33
45
  gem 'mysql2', '~> 0.5.2'
34
46
 
35
47
  group :test do
36
- # TestUnit was removed from Ruby 2.2 but still needed for testing Rails 3.x.
37
- gem 'test-unit', '~> 3.0' if RUBY_VERSION >= '2.2'
48
+ gem 'machinist', '~> 1.0.6'
49
+ gem 'rspec', '~> 3'
38
50
  gem 'simplecov', :require => false
39
51
  end
data/README.md CHANGED
@@ -3,17 +3,7 @@
3
3
  [![Build Status](https://travis-ci.org/activerecord-hackery/ransack.svg)](https://travis-ci.org/activerecord-hackery/ransack)
4
4
  [![Gem Version](https://badge.fury.io/rb/ransack.svg)](http://badge.fury.io/rb/ransack)
5
5
  [![Code Climate](https://codeclimate.com/github/activerecord-hackery/ransack/badges/gpa.svg)](https://codeclimate.com/github/activerecord-hackery/ransack)
6
- [![Backers on Open Collective](https://opencollective.com/ransack/backers/badge.svg)](#backers) [![Sponsors on Open Collective](https://opencollective.com/ransack/sponsors/badge.svg)](#sponsors)
7
-
8
- Ransack is a rewrite of [MetaSearch](https://github.com/activerecord-hackery/meta_search)
9
- created by [Ernie Miller](http://twitter.com/erniemiller)
10
- and developed/maintained for years by
11
- [Jon Atack](http://twitter.com/jonatack) and
12
- [Ryan Bigg](http://twitter.com/ryanbigg) with the help of a great group of
13
- [contributors](https://github.com/activerecord-hackery/ransack/graphs/contributors). Ransack's logo is designed by [Anıl Kılıç](https://github.com/anilkilic).
14
- While it supports many of the same features as MetaSearch, its underlying
15
- implementation differs greatly from MetaSearch,
16
- and backwards compatibility is not a design goal.
6
+ [![Backers on Open Collective](https://opencollective.com/ransack/backers/badge.svg)](#backers) [![Sponsors on Open Collective](https://opencollective.com/ransack/sponsors/badge.svg)](#sponsors)
17
7
 
18
8
  Ransack enables the creation of both
19
9
  [simple](http://ransack-demo.herokuapp.com) and
@@ -25,25 +15,9 @@ or controller layer, you're probably not looking for Ransack (or MetaSearch,
25
15
  for that matter). Try [Squeel](https://github.com/activerecord-hackery/squeel)
26
16
  instead.
27
17
 
28
- If you're viewing this at
29
- [github.com/activerecord-hackery/ransack](https://github.com/activerecord-hackery/ransack),
30
- you're reading the documentation for the master branch with the latest features.
31
- [View documentation for the last release (2.0.0).](https://github.com/activerecord-hackery/ransack/tree/v2.0.0)
32
-
33
- ## Rails 6 Support
34
-
35
- Rails 6 is right around the corner, but not yet released. Ransack master branch supports ```6.0.0.rc2```. Full Rails 6 support will be provided after the official Rails 6 release. See [this issue](https://github.com/activerecord-hackery/ransack/issues/1032) for details.
36
-
37
18
  ## Getting started
38
19
 
39
- Ransack is compatible with Rails 6.0.0.rc2, 5.0, 5.1 and 5.2 on Ruby 2.2 and later.
40
- If you are using Rails <5.0 use the 1.8 line of Ransack.
41
- If you are using Ruby 1.8 or an earlier JRuby and run into compatibility
42
- issues, you can use an earlier version of Ransack, say, up to 1.3.0.
43
-
44
- Ransack works out-of-the-box with Active Record and also features limited
45
- support for Mongoid 4 and 5 (without associations, further details
46
- [below](https://github.com/activerecord-hackery/ransack#mongoid)).
20
+ Ransack is compatible with Rails 6.0, 5.0, 5.1 and 5.2 on Ruby 2.3 and later.
47
21
 
48
22
  In your Gemfile, for the last officially released gem:
49
23
 
@@ -489,6 +463,12 @@ List of all possible predicates
489
463
  | `*_not_cont` | Does not contain |
490
464
  | `*_not_cont_any` | Does not contain any of | |
491
465
  | `*_not_cont_all` | Does not contain all of | |
466
+ | `*_i_cont` | Contains value with case insensitive | uses `LIKE` |
467
+ | `*_i_cont_any` | Contains any of values with case insensitive | |
468
+ | `*_i_cont_all` | Contains all of values with case insensitive | |
469
+ | `*_not_i_cont` | Does not contain with case insensitive |
470
+ | `*_not_i_cont_any` | Does not contain any of values with case insensitive | |
471
+ | `*_not_i_cont_all` | Does not contain all of values with case insensitive | |
492
472
  | `*_true` | is true | |
493
473
  | `*_false` | is false | |
494
474
 
@@ -755,7 +735,7 @@ To turn this off on a per-scope basis Ransack adds the following method to
755
735
  Add the scope you wish to bypass this behavior to ransackable_scopes_skip_sanitize_args:
756
736
 
757
737
  ```ruby
758
- def ransackable_scopes_skip_sanitize_args
738
+ def self.ransackable_scopes_skip_sanitize_args
759
739
  [:scope_to_skip_sanitize_args]
760
740
  end
761
741
  ```
@@ -926,6 +906,7 @@ In other words: `Major.Minor.Patch`.
926
906
 
927
907
  To support the project:
928
908
 
909
+ * Consider supporting via [Open Collective](https://opencollective.com/ransack/backers/badge.svg)
929
910
  * Use Ransack in your apps, and let us know if you encounter anything that's
930
911
  broken or missing. A failing spec to demonstrate the issue is awesome. A pull
931
912
  request with passing tests is even better!
@@ -941,6 +922,21 @@ fix bugs!
941
922
 
942
923
  This project exists thanks to all the people who contribute. <img src="https://opencollective.com/ransack/contributors.svg?width=890&button=false" />
943
924
 
925
+ Ransack is a rewrite of [MetaSearch](https://github.com/activerecord-hackery/meta_search)
926
+ created by [Ernie Miller](http://twitter.com/erniemiller)
927
+ and developed/maintained by:
928
+
929
+ - [Greg Molnar](https://github.com/gregmolnar)
930
+ - [Deivid Rodriguez](https://github.com/deivid-rodriguez)
931
+ - [Sean Carroll](https://github.com/seanfcarroll)
932
+ - [Jon Atack](http://twitter.com/jonatack)
933
+ - [Ryan Bigg](http://twitter.com/ryanbigg)
934
+ - a great group of [contributors](https://github.com/activerecord-hackery/ransack/graphs/contributors).
935
+ - Ransack's logo is designed by [Anıl Kılıç](https://github.com/anilkilic).
936
+
937
+ While it supports many of the same features as MetaSearch, its underlying implementation differs greatly from MetaSearch, and backwards compatibility is not a design goal.
938
+
939
+
944
940
 
945
941
  ## Backers
946
942
 
@@ -963,5 +959,3 @@ Support this project by becoming a sponsor. Your logo will show up here with a l
963
959
  <a href="https://opencollective.com/ransack/sponsor/7/website" target="_blank"><img src="https://opencollective.com/ransack/sponsor/7/avatar.svg"></a>
964
960
  <a href="https://opencollective.com/ransack/sponsor/8/website" target="_blank"><img src="https://opencollective.com/ransack/sponsor/8/avatar.svg"></a>
965
961
  <a href="https://opencollective.com/ransack/sponsor/9/website" target="_blank"><img src="https://opencollective.com/ransack/sponsor/9/avatar.svg"></a>
966
-
967
-
@@ -21,12 +21,11 @@ end
21
21
 
22
22
  require 'ransack/search'
23
23
  require 'ransack/ransacker'
24
- require 'ransack/helpers'
25
- require 'action_controller'
26
24
  require 'ransack/translate'
27
25
 
28
26
  Ransack::Adapters.object_mapper.require_adapter
29
27
 
30
28
  ActiveSupport.on_load(:action_controller) do
29
+ require 'ransack/helpers'
31
30
  ActionController::Base.helper Ransack::Helpers::FormHelper
32
31
  end
@@ -6,13 +6,6 @@ module Ransack
6
6
  module ActiveRecord
7
7
  class Context < ::Ransack::Context
8
8
 
9
- def initialize(object, options = {})
10
- super
11
- if ::ActiveRecord::VERSION::STRING < Constants::RAILS_5_2
12
- @arel_visitor = @engine.connection.visitor
13
- end
14
- end
15
-
16
9
  def relation_for(object)
17
10
  object.all
18
11
  end
@@ -104,8 +97,7 @@ module Ransack
104
97
  # JoinDependency to track table aliases.
105
98
  #
106
99
  def join_sources
107
- base, joins =
108
- if ::ActiveRecord::VERSION::STRING > Constants::RAILS_5_2_0
100
+ base, joins = begin
109
101
  alias_tracker = ::ActiveRecord::Associations::AliasTracker.create(self.klass.connection, @object.table.name, [])
110
102
  constraints = if ::Gem::Version.new(::ActiveRecord::VERSION::STRING) >= ::Gem::Version.new(Constants::RAILS_6_0)
111
103
  @join_dependency.join_constraints(@object.joins_values, alias_tracker)
@@ -117,13 +109,7 @@ module Ransack
117
109
  Arel::SelectManager.new(@object.table),
118
110
  constraints
119
111
  ]
120
- else
121
- [
122
- Arel::SelectManager.new(@object.table),
123
- @join_dependency.join_constraints(@object.joins_values, @join_type)
124
- ]
125
112
  end
126
- joins = joins.collect(&:joins).flatten if ::ActiveRecord::VERSION::STRING < Constants::RAILS_5_2
127
113
  joins.each do |aliased_join|
128
114
  base.from(aliased_join)
129
115
  end
@@ -268,28 +254,15 @@ module Ransack
268
254
 
269
255
  join_list = join_nodes + convert_join_strings_to_ast(relation.table, string_joins)
270
256
 
271
- if ::ActiveRecord::VERSION::STRING < Constants::RAILS_5_2_0
272
- join_dependency = Polyamorous::JoinDependency.new(relation.klass, association_joins, join_list)
273
- join_nodes.each do |join|
274
- join_dependency.send(:alias_tracker).aliases[join.left.name.downcase] = 1
275
- end
276
- elsif ::ActiveRecord::VERSION::STRING == Constants::RAILS_5_2_0
277
- alias_tracker = ::ActiveRecord::Associations::AliasTracker.create(self.klass.connection, relation.table.name, join_list)
278
- join_dependency = Polyamorous::JoinDependency.new(relation.klass, relation.table, association_joins, alias_tracker)
279
- join_nodes.each do |join|
280
- join_dependency.send(:alias_tracker).aliases[join.left.name.downcase] = 1
281
- end
257
+ alias_tracker = ::ActiveRecord::Associations::AliasTracker.create(self.klass.connection, relation.table.name, join_list)
258
+ join_dependency = if ::Gem::Version.new(::ActiveRecord::VERSION::STRING) >= ::Gem::Version.new(Constants::RAILS_6_0)
259
+ Polyamorous::JoinDependency.new(relation.klass, relation.table, association_joins, Arel::Nodes::OuterJoin)
282
260
  else
283
- alias_tracker = ::ActiveRecord::Associations::AliasTracker.create(self.klass.connection, relation.table.name, join_list)
284
- join_dependency = if ::Gem::Version.new(::ActiveRecord::VERSION::STRING) >= ::Gem::Version.new(Constants::RAILS_6_0)
285
- Polyamorous::JoinDependency.new(relation.klass, relation.table, association_joins, Arel::Nodes::OuterJoin)
286
- else
287
- Polyamorous::JoinDependency.new(relation.klass, relation.table, association_joins)
288
- end
289
- join_dependency.instance_variable_set(:@alias_tracker, alias_tracker)
290
- join_nodes.each do |join|
291
- join_dependency.send(:alias_tracker).aliases[join.left.name.downcase] = 1
292
- end
261
+ Polyamorous::JoinDependency.new(relation.klass, relation.table, association_joins)
262
+ end
263
+ join_dependency.instance_variable_set(:@alias_tracker, alias_tracker)
264
+ join_nodes.each do |join|
265
+ join_dependency.send(:alias_tracker).aliases[join.left.name.downcase] = 1
293
266
  end
294
267
  join_dependency
295
268
  end
@@ -321,22 +294,6 @@ module Ransack
321
294
  @join_type
322
295
  )
323
296
  found_association = jd.instance_variable_get(:@join_root).children.last
324
- elsif ::Gem::Version.new(::ActiveRecord::VERSION::STRING) < ::Gem::Version.new(Constants::RAILS_5_2_0)
325
- jd = Polyamorous::JoinDependency.new(
326
- parent.base_klass,
327
- Polyamorous::Join.new(name, @join_type, klass),
328
- []
329
- )
330
- found_association = jd.join_root.children.last
331
- elsif ::ActiveRecord::VERSION::STRING == Constants::RAILS_5_2_0
332
- alias_tracker = ::ActiveRecord::Associations::AliasTracker.create(self.klass.connection, parent.table.name, [])
333
- jd = Polyamorous::JoinDependency.new(
334
- parent.base_klass,
335
- parent.table,
336
- Polyamorous::Join.new(name, @join_type, klass),
337
- alias_tracker
338
- )
339
- found_association = jd.instance_variable_get(:@join_root).children.last
340
297
  else
341
298
  jd = Polyamorous::JoinDependency.new(
342
299
  parent.base_klass,
@@ -353,11 +310,7 @@ module Ransack
353
310
  @join_dependency.instance_variable_get(:@join_root).children.push found_association
354
311
 
355
312
  # Builds the arel nodes properly for this association
356
- if ::ActiveRecord::VERSION::STRING > Constants::RAILS_5_2_0
357
- @join_dependency.send(:construct_tables!, jd.instance_variable_get(:@join_root))
358
- else
359
- @join_dependency.send(:construct_tables!, jd.instance_variable_get(:@join_root), found_association)
360
- end
313
+ @join_dependency.send(:construct_tables!, jd.instance_variable_get(:@join_root))
361
314
 
362
315
  # Leverage the stashed association functionality in AR
363
316
  @object = @object.joins(jd)
@@ -367,32 +320,12 @@ module Ransack
367
320
  def extract_joins(association)
368
321
  parent = @join_dependency.instance_variable_get(:@join_root)
369
322
  reflection = association.reflection
370
- join_constraints = if ::ActiveRecord::VERSION::STRING < Constants::RAILS_5_1
371
- association.join_constraints(
372
- parent.table,
373
- parent.base_klass,
374
- association,
375
- Arel::Nodes::OuterJoin,
376
- association.tables,
377
- reflection.scope_chain,
378
- reflection.chain
379
- )
380
- elsif ::ActiveRecord::VERSION::STRING <= Constants::RAILS_5_2_0
381
- association.join_constraints(
382
- parent.table,
383
- parent.base_klass,
384
- Arel::Nodes::OuterJoin,
385
- association.tables,
386
- reflection.chain
387
- )
388
- else
389
- association.join_constraints(
323
+ join_constraints = association.join_constraints(
390
324
  parent.table,
391
325
  parent.base_klass,
392
326
  Arel::Nodes::OuterJoin,
393
327
  @join_dependency.instance_variable_get(:@alias_tracker)
394
328
  )
395
- end
396
329
  join_constraints.to_a.flatten
397
330
  end
398
331
  end
@@ -13,6 +13,18 @@ module Ransack
13
13
  formatter: proc { |v| "%#{escape_wildcards(v)}%" }
14
14
  }
15
15
  ],
16
+ ['i_cont'.freeze, {
17
+ arel_predicate: 'matches'.freeze,
18
+ formatter: proc { |v| "%#{escape_wildcards(v.downcase)}%" },
19
+ case_insensitive: true
20
+ }
21
+ ],
22
+ ['not_i_cont'.freeze, {
23
+ arel_predicate: 'does_not_match'.freeze,
24
+ formatter: proc { |v| "%#{escape_wildcards(v.downcase)}%" },
25
+ case_insensitive: true
26
+ }
27
+ ],
16
28
  ['start'.freeze, {
17
29
  arel_predicate: 'matches'.freeze,
18
30
  formatter: proc { |v| "#{escape_wildcards(v)}%" }
@@ -30,12 +30,7 @@ module Ransack
30
30
  @associations_pot = {}
31
31
  @lock_associations = []
32
32
 
33
- if ::ActiveRecord::VERSION::STRING >= Constants::RAILS_5_2
34
- @base = @join_dependency.instance_variable_get(:@join_root)
35
- else
36
- @base = @join_dependency.join_root
37
- @engine = @base.base_klass.arel_engine
38
- end
33
+ @base = @join_dependency.instance_variable_get(:@join_root)
39
34
  end
40
35
 
41
36
  def bind_pair_for(key)
@@ -30,7 +30,7 @@ module Ransack
30
30
  def format_predicate(attribute)
31
31
  arel_pred = arel_predicate_for_attribute(attribute)
32
32
  arel_values = formatted_values_for_attribute(attribute)
33
- predicate = attribute.attr.public_send(arel_pred, arel_values)
33
+ predicate = attr_value_for_attribute(attribute).public_send(arel_pred, arel_values)
34
34
 
35
35
  if in_predicate?(predicate)
36
36
  predicate.right = predicate.right.map do |pr|
@@ -45,9 +45,6 @@ module Ransack
45
45
  NOT_EQ_ALL = 'not_eq_all'.freeze
46
46
  CONT = 'cont'.freeze
47
47
 
48
- RAILS_5_1 = '5.1'.freeze
49
- RAILS_5_2 = '5.2'.freeze
50
- RAILS_5_2_0 = '5.2.0'.freeze
51
48
  RAILS_6_0 = '6.0.0'.freeze
52
49
 
53
50
  RANSACK_SLASH_SEARCHES = 'ransack/searches'.freeze
@@ -7,17 +7,11 @@ module ActionView::Helpers::Tags
7
7
  class Base
8
8
  private
9
9
  if defined? ::ActiveRecord
10
- if ::ActiveRecord::VERSION::STRING < '5.2'
11
- def value(object)
12
- object.send @method_name if object # use send instead of public_send
13
- end
14
- else # rails/rails#29791
15
- def value
16
- if @allow_method_names_outside_object
17
- object.send @method_name if object && object.respond_to?(@method_name, true)
18
- else
19
- object.send @method_name if object
20
- end
10
+ def value
11
+ if @allow_method_names_outside_object
12
+ object.send @method_name if object && object.respond_to?(@method_name, true)
13
+ else
14
+ object.send @method_name if object
21
15
  end
22
16
  end
23
17
  end