Skip to content

Commit 4b99677

Browse files
authored
Merge pull request #4 from davidwparker/use-resource-namespace
Use the namespace for the active admin resource.
2 parents dd5c512 + f9b5de2 commit 4b99677

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

README.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ based on the input attribute name, you can pass an object with a
138138
end
139139
```
140140

141-
#### Mutlple Options Endpoints per Resource
141+
#### Multiple Options Endpoints per Resource
142142

143143
A single ActiveAdmin resource can define multiple options endpoints:
144144

@@ -167,6 +167,23 @@ To specify which collection to use, pass an object with a
167167
end
168168
```
169169

170+
#### Querying Multiple Attributes
171+
172+
ActiveAdmin Searchable Select querying is performed by Ransack. As such, you can
173+
build your query in a way that it can query multiple attributes at once.
174+
175+
```ruby
176+
ActiveAdmin.register User do
177+
searchable_select_options(scope: User.all,
178+
text_attribute: :username,
179+
filter: lambda do |term, scope|
180+
scope.ransack(email_or_username_cont: term).result
181+
end)
182+
end
183+
```
184+
185+
In this example, the `all` scope will query `email OR username`.
186+
170187
#### Passing Parameters
171188

172189
You can pass additional parameters to the options endpoint:

lib/activeadmin/searchable_select/select_input_extension.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def collection_from_options
4545

4646
def ajax_url
4747
return unless options[:ajax]
48-
template.polymorphic_path([:admin, ajax_resource_class],
48+
template.polymorphic_path([template.active_admin_namespace.name, ajax_resource_class],
4949
action: option_collection.collection_action_name,
5050
**ajax_params)
5151
end

0 commit comments

Comments
 (0)