Skip to content

Commit

Permalink
fix: search when link_to_child_resource (#2635)
Browse files Browse the repository at this point in the history
* fix: search when link_to_child_resource

* lint
  • Loading branch information
Paul-Bob committed Mar 27, 2024
1 parent 948f83d commit c47ce1a
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion app/controllers/avo/search_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,16 @@ def fetch_result_information(record, resource, item)
title = item&.dig(:title) || resource.record_title
highlighted_title = highlight(title&.to_s, params[:q])

record_path = if resource.link_to_child_resource
Avo.resource_manager.get_resource_by_model_class(record.class).new(record: record).record_path
else
resource.record_path
end

{
_id: record.id,
_label: highlighted_title,
_url: resource.class.fetch_search(:result_path, record: resource.record) || resource.record_path
_url: resource.class.fetch_search(:result_path, record: resource.record) || record_path
}
end

Expand Down

0 comments on commit c47ce1a

Please sign in to comment.