Split Poll::Booth.search in two methods

We use this method in two different scenarios. In an AJAX request, we
don't want to return every booth if the search is blank. However, in a
normal HTTP GET request, we want to return every record when the search
is empty, as we do everywhere else.

It's possible the behaviour of the AJAX call is unusual, since it
searches all booths, and not just the ones assigned to a poll. If we
changed this behaviour, we could simplify the code and remove the
`quick_search` method.
This commit is contained in:
Javi Martín
2019-10-01 02:19:41 +02:00
parent 24e4f4518f
commit 710a1d8357
4 changed files with 31 additions and 4 deletions

View File

@@ -9,7 +9,7 @@ class Admin::Poll::BoothAssignmentsController < Admin::Poll::BaseController
def search_booths
load_search
@booths = ::Poll::Booth.search(@search)
@booths = ::Poll::Booth.quick_search(@search)
respond_to do |format|
format.js
end