Skip to content

Commit 87aa421

Browse files
authored
Merge pull request #477 from platanus/activeadmin-v3-support
Activeadmin v3 support
2 parents 070c754 + faea79f commit 87aa421

17 files changed

+84
-22
lines changed

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ This project adheres to [Semantic Versioning](http://semver.org/).
66

77
#### Added
88

9-
* Add Ruby 3.2 support
9+
* Add Ruby 3.2 support [#474](https://github.com/platanus/activeadmin_addons/pull/474)
10+
* Add ActiveAdmin v3 support [#477](https://github.com/platanus/activeadmin_addons/pull/477)
11+
* Note that changes made should be backwards compatible with ActiveAdmin 2.x, so this is not a breaking change
1012

1113
### 2.0.0.beta-2
1214

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ gemspec
1212

1313
# To use debugger
1414
# gem "debugger"
15-
gem "activeadmin"
15+
gem "activeadmin", '~> 3.0'
1616
gem "mimemagic", github: "mimemagicrb/mimemagic", ref: "01f92d86d15d85cfd0f20dabd025dcbd36a8a60f"
1717

1818
gem "webpacker", "~> 5.4"

Gemfile.lock

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,15 @@ GEM
5757
erubi (~> 1.4)
5858
rails-dom-testing (~> 2.0)
5959
rails-html-sanitizer (~> 1.1, >= 1.2.0)
60-
activeadmin (2.13.1)
60+
activeadmin (3.0.0)
6161
arbre (~> 1.2, >= 1.2.1)
6262
formtastic (>= 3.1, < 5.0)
6363
formtastic_i18n (~> 0.4)
6464
inherited_resources (~> 1.7)
6565
jquery-rails (~> 4.2)
6666
kaminari (~> 1.0, >= 1.2.1)
6767
railties (>= 6.1, < 7.1)
68-
ransack (>= 2.1.1, < 4)
68+
ransack (>= 4.0, < 5)
6969
activejob (6.1.7)
7070
activesupport (= 6.1.7)
7171
globalid (>= 0.3.6)
@@ -89,7 +89,7 @@ GEM
8989
zeitwerk (~> 2.3)
9090
addressable (2.8.5)
9191
public_suffix (>= 2.0.2, < 6.0)
92-
arbre (1.5.0)
92+
arbre (1.6.0)
9393
activesupport (>= 3.0.0, < 7.1)
9494
ruby2_keywords (>= 0.0.2, < 1.0)
9595
ast (2.4.2)
@@ -139,7 +139,7 @@ GEM
139139
guard (~> 2.1)
140140
guard-compat (~> 1.1)
141141
rspec (>= 2.99.0, < 4.0)
142-
has_scope (0.8.0)
142+
has_scope (0.8.1)
143143
actionpack (>= 5.2)
144144
activesupport (>= 5.2)
145145
i18n (1.12.0)
@@ -241,19 +241,19 @@ GEM
241241
thor (~> 1.0)
242242
rainbow (3.1.1)
243243
rake (13.0.6)
244-
ransack (3.0.1)
245-
activerecord (>= 6.0.4)
246-
activesupport (>= 6.0.4)
244+
ransack (4.0.0)
245+
activerecord (>= 6.1.5)
246+
activesupport (>= 6.1.5)
247247
i18n
248248
rb-fsevent (0.11.2)
249249
rb-inotify (0.10.1)
250250
ffi (~> 1.0)
251251
redcarpet (3.6.0)
252252
regexp_parser (2.8.1)
253253
require_all (3.0.0)
254-
responders (3.0.1)
255-
actionpack (>= 5.0)
256-
railties (>= 5.0)
254+
responders (3.1.0)
255+
actionpack (>= 5.2)
256+
railties (>= 5.2)
257257
rexml (3.2.5)
258258
rspec (3.9.0)
259259
rspec-core (~> 3.9.0)
@@ -353,7 +353,7 @@ PLATFORMS
353353

354354
DEPENDENCIES
355355
aasm
356-
activeadmin
356+
activeadmin (~> 3.0)
357357
activeadmin_addons!
358358
capybara
359359
database_cleaner

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/app/models/category.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
class Category < ActiveRecord::Base
22
has_many :invoices
3+
34
def shiny_name
45
"My shiny #{name}"
56
end
7+
8+
def self.ransackable_attributes(_auth_object = nil)
9+
["created_at", "description", "id", "name", "updated_at"]
10+
end
11+
12+
def self.ransackable_associations(_auth_object = nil)
13+
["invoices"]
14+
end
615
end

0 commit comments

Comments
 (0)