Skip to content

Commit 73a3d87

Browse files
committed
feat(): remove use of custom ransack predicates
Mainly, the 'contains' predicate, that was used as default in some components. These predicates were removed from activeadmin v3, since they were backports. More info here activeadmin/activeadmin#8010
1 parent c913697 commit 73a3d87

File tree

8 files changed

+9
-9
lines changed

8 files changed

+9
-9
lines changed

app/inputs/nested_level_input.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def load_control_attributes
1818
load_class(@options[:class])
1919
load_data_attr(:association, value: association_name)
2020
load_data_attr(:fields, default: ["name"], formatter: :to_json)
21-
load_data_attr(:predicate, default: "contains")
21+
load_data_attr(:predicate, default: "cont")
2222
load_data_attr(:filters)
2323
load_data_attr(:model, value: model_name)
2424
load_data_attr(:display_name, default: "name")

app/inputs/search_select_input.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def input_method
1515
def load_control_attributes
1616
load_class(@options[:class])
1717
load_data_attr(:fields, default: ["name"], formatter: :to_json)
18-
load_data_attr(:predicate, default: "contains")
18+
load_data_attr(:predicate, default: "cont")
1919
load_data_attr(:url, default: url_from_method)
2020
load_data_attr(:response_root, default: tableize_method)
2121
load_data_attr(:display_name, default: "name")

app/inputs/selected_list_input.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def load_control_attributes
1111
load_data_attr(:url, default: url_from_method)
1212
load_data_attr(:response_root, default: tableize_method)
1313
load_data_attr(:fields, default: ["name"], formatter: :to_json)
14-
load_data_attr(:predicate, default: "contains")
14+
load_data_attr(:predicate, default: "cont")
1515
load_data_attr(:display_name, default: "name")
1616
load_data_attr(:minimum_input_length, default: 1)
1717
load_data_attr(:width, default: "100%")

docs/slim-select_nested_select.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ Nested select, allows you to customize the general behavior of the input:
9191
* `display_name`: **(optional)** You can pass an optional `display_name` to set the attribute (or method) to show results on the select. It **defaults to**: `name`
9292
* `minimum_input_length`: **(optional)** Minimum number of characters required to initiate the search. It **defaults to**: `1`. Set this value to `0` to disable type-to-search and show a static list.
9393
* `response_root`: **(optional)** If you have defined the `url` attribute and a request to that url responds with a root, you can indicate the name of that root with this attribute. By default, the gem will try to infer the root from the name of the input. If you have a rootless api, you don't need to worry about this attribute.
94-
* `predicate`: **(optional)** You can change the default [ransack predicate](https://github.com/activerecord-hackery/ransack#search-matchers). It **defaults to** `contains`
94+
* `predicate`: **(optional)** You can change the default [ransack predicate](https://github.com/activerecord-hackery/ransack#search-matchers). It **defaults to** `cont`
9595

9696
```ruby
9797
f.input :city, as: :nested_select,
@@ -139,7 +139,7 @@ f.input :city, as: :nested_select,
139139
level_1: { attribute: :country },
140140
level_2: {
141141
attribute: :region,
142-
filters: { name_contains: "Cuy", id_gt: 22 }
142+
filters: { name_cont: "Cuy", id_gt: 22 }
143143
},
144144
level_3: { attribute: :city }
145145
```

docs/slim-select_search.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,5 +43,5 @@ Note that in this case you need to use the `id` instead of the name of the assoc
4343
* `class`: **(optional)** You can pass extra classes for your field.
4444
* `width`: **(optional)** You can set the select input width (px or %).
4545
* `order_by`: **(optional)** Order (sort) results by a specific attribute, suffixed with `_desc` or `_asc`. Eg: `description_desc`. By **default** is used the first field in descending direction.
46-
* `predicate`: **(optional)** You can change the default [ransack predicate](https://github.com/activerecord-hackery/ransack#search-matchers). It **defaults to** `contains`.
46+
* `predicate`: **(optional)** You can change the default [ransack predicate](https://github.com/activerecord-hackery/ransack#search-matchers). It **defaults to** `cont`.
4747
* `method_model`: **(optional)** Use in case you need to search or filter an attribute of another table.

docs/slim-select_selected_list.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,4 @@ To get...
3737
* `display_name`: **(optional)** You can pass an optional `display_name` to set the attribute to show results on the select. It **defaults to**: `name`.
3838
* `width`: **(optional)** You can set the select input width (px or %).
3939
* `order_by`: **(optional)** Order (sort) results by a specific attribute, suffixed with `_desc` or `_asc`. Eg: `description_desc`. By **default** is used the first field in descending direction.
40-
* `predicate`: **(optional)** You can change the default [ransack predicate](https://github.com/activerecord-hackery/ransack#search-matchers). It **defaults to** `contains`
40+
* `predicate`: **(optional)** You can change the default [ransack predicate](https://github.com/activerecord-hackery/ransack#search-matchers). It **defaults to** `cont`

spec/dummy/config/initializers/active_admin.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@
303303
# :title,
304304
# :email,
305305
# ]
306-
# config.filter_method_for_large_association, '_starts_with'
306+
# config.filter_method_for_large_association, '_start'
307307

308308
# == Head
309309
#

spec/features/inputs/nested_select_input_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@
242242
level_1: { attribute: :country },
243243
level_2: {
244244
attribute: :region,
245-
filters: { name_contains: 'Met' }
245+
filters: { name_cont: 'Met' }
246246
},
247247
level_3: { attribute: :city }
248248
end

0 commit comments

Comments
 (0)