You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -48,39 +48,39 @@ By default, the nested select input uses the index action of the different level
48
48
It's not mandatory to register the ActiveAdmin pages. But, if you don't, you'll need to pass the `url` attribute, on each level, to make it work.
49
49
50
50
```ruby
51
-
f.input :city_id, as::nested_select,
52
-
level_1: {
53
-
attribute::country_id,
54
-
url:'/api/countries'
55
-
},
56
-
level_2: {
57
-
attribute::region_id,
58
-
url:'/api/regions'
59
-
},
60
-
level_3: {
61
-
attribute::city_id,
62
-
url:'/api/cities'
63
-
}
51
+
f.input :city, as::nested_select,
52
+
level_1: {
53
+
attribute::country,
54
+
url:'/api/countries'
55
+
},
56
+
level_2: {
57
+
attribute::region,
58
+
url:'/api/regions'
59
+
},
60
+
level_3: {
61
+
attribute::city,
62
+
url:'/api/cities'
63
+
}
64
64
```
65
65
66
66
> Remember: those custom endpoints need to work with Ransack filters.
67
67
68
68
Another option is to pass the `collection` attribute. If you set this, the `url` attribute will be ignored (no ajax request will be executed) and you will work with preloaded collections.
69
69
70
70
```ruby
71
-
f.input :city_id, as::nested_select,
72
-
level_1: {
73
-
attribute::country_id,
74
-
collection:Country.all
75
-
},
76
-
level_2: {
77
-
attribute::region_id,
78
-
collection:Region.active
79
-
},
80
-
level_3: {
81
-
attribute::city_id,
82
-
collection:City.all
83
-
}
71
+
f.input :city, as::nested_select,
72
+
level_1: {
73
+
attribute::country,
74
+
collection:Country.all
75
+
},
76
+
level_2: {
77
+
attribute::region,
78
+
collection:Region.active
79
+
},
80
+
level_3: {
81
+
attribute::city,
82
+
collection:City.all
83
+
}
84
84
```
85
85
86
86
### Options
@@ -94,38 +94,38 @@ Nested select, allows you to customize the general behavior of the input:
94
94
*`predicate`: **(optional)** You can change the default [ransack predicate](https://github.com/activerecord-hackery/ransack#search-matchers). It **defaults to**`contains`
Note that in this case you need to use the `id` instead of the name of the association, just like you would do in a normal filter that uses an attribute of an association.
33
34
34
35
### Options
35
36
36
-
*`category_id`: Notice we're using the relation field name, not the relation itself, so you can't use `f.input :category`.
37
37
*`url`: This is the URL where to get the results. This URL expects an activeadmin collection Url (like the index action) or anything that uses [ransack](https://github.com/activerecord-hackery/ransack) search gem.
38
38
*`response_root`: **(optional)** If a request to `url` responds with root, you can indicate the name of that root with this attribute. By default, the gem will try to infer the root from url. For example: if `url` is `GET /admin/categories`, the root will be `categories`. If you have a rootless api, you don't need to worry about this attribute.
39
39
*`fields`: an array of field names where to search for matches in the related model (`Category` in this example). If we give many fields, they will be searched with an OR condition.
0 commit comments