Skip to content

Commit 07bf49f

Browse files
committed
Always construct ajax url based on resource collection path
No need to fall back to constructing it via `polymorphic_path` since if we cannot fine the admin resource to get `route_collection_path`, we will also not be able to use to determine `ajax_resource_class`.
1 parent d1eb35a commit 07bf49f

File tree

1 file changed

+5
-13
lines changed

1 file changed

+5
-13
lines changed

lib/activeadmin/searchable_select/select_input_extension.rb

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -45,19 +45,11 @@ def collection_from_options
4545

4646
def ajax_url
4747
return unless options[:ajax]
48-
template.polymorphic_path([active_admin_prefix, resource_route_name || ajax_resource_class],
49-
action: option_collection.collection_action_name,
50-
**ajax_params)
51-
end
52-
53-
def active_admin_prefix
54-
template.active_admin_namespace.route_prefix
55-
end
56-
57-
def resource_route_name
58-
active_admin_namespace = template.active_admin_namespace
59-
str = active_admin_namespace.resource_for(ajax_resource_class)&.route_collection_path
60-
str&.split('/')&.last
48+
[ajax_resource.route_collection_path,
49+
'/',
50+
option_collection.collection_action_name,
51+
'?',
52+
ajax_params.to_query].join
6153
end
6254

6355
def all_options_collection

0 commit comments

Comments
 (0)