Skip to content

Commit

Permalink
Fix preview if search_result_page is nil
Browse files Browse the repository at this point in the history
If you create the search page for the first time there is the possibility that the search_result_page is nil. Add safe operators to prevent an exception in that case.
  • Loading branch information
sascha-karnatz committed Oct 3, 2024
1 parent bdf7353 commit f128eae
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion app/controller/alchemy/pg_search/controller_methods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def paginate_per

def set_preview_query
if self.class == Alchemy::Admin::PagesController && params[:query].blank?
element = search_result_page.draft_version.elements.named(:searchresults).first
element = search_result_page&.draft_version&.elements&.named(:searchresults)&.first

params[:query] = element&.value_for("search_string") || "lorem"
end
Expand Down

0 comments on commit f128eae

Please sign in to comment.