mirror of
https://github.com/internetee/registry.git
synced 2025-05-19 18:59:38 +02:00
Add pattern matching for domain name field in search #2122
This commit is contained in:
parent
31d19ff64e
commit
4b9e082712
3 changed files with 12 additions and 3 deletions
|
@ -15,6 +15,16 @@ class Admin::DomainsController < AdminController
|
|||
normalize_search_parameters do
|
||||
@q = domains.search(params[:q])
|
||||
@domains = @q.result.page(params[:page])
|
||||
if @domains.count == 1
|
||||
redirect_to [:admin, @domains.first] and return
|
||||
elsif @domains.count == 0 && params[:q][:name_matches] !~ /^%.+%$/
|
||||
# if we do not get any results, add wildcards to the name field and search again
|
||||
n_cache = params[:q][:name_matches]
|
||||
params[:q][:name_matches] = "%#{params[:q][:name_matches]}%"
|
||||
@q = domains.search(params[:q])
|
||||
@domains = @q.result.page(params[:page])
|
||||
params[:q][:name_matches] = n_cache # we don't want to show wildcards in search form
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue