Skip to content

Commit 258bf1d

Browse files
committed
docs(slim-select-search): response_root infers name from input name
1 parent 6f8ec1d commit 258bf1d

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

docs/slim-select_search.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,14 @@ In case you need to filter with an attribute of another table you need to includ
2828
```ruby
2929
filter :posts_user_id, as: :search_select_filter, url: proc { admin_users_path },
3030
fields: [:name, :email], display_name: 'email', minimum_input_length: 2,
31-
order_by: 'description_asc', method_model: User
31+
order_by: 'description_asc', method_model: User, response_root: :users
3232
```
3333
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.
3434

3535
### Options
3636

3737
* `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-
* `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.
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 the name of the input or filter, so it is needed when using a filter on an attribute of another table for example. If you have a rootless api, you don't need to worry about this attribute.
3939
* `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.
4040
* `display_name`: **(optional)** You can pass an optional `display_name` to set the field to show results on the select. This will be the field read from the object on loading the form and also when reading data from the ajax response(on the JSON). It **defaults to**: `name`
4141
* `minimum_input_length`: **(optional)** Minimum number of characters required to initiate the

0 commit comments

Comments
 (0)