diff options
| author | Teddy Wing | 2018-02-26 14:45:58 +0100 |
|---|---|---|
| committer | Johan Van Ryseghem | 2018-03-07 13:19:41 +0100 |
| commit | f372eda831e91da367007f3e0aef725c6a67c574 (patch) | |
| tree | e3d22c00c4c65ab4e7e53d2b0a00e4578c8d8ec1 | |
| parent | f43442404d37cfb04b012c73c24b1dc4bf01168d (diff) | |
| download | chouette-core-f372eda831e91da367007f3e0aef725c6a67c574.tar.bz2 | |
AutocompleteLinesController: Move filter SQL string inside query
Get rid of the heredoc to allow us to put the string inside the argument
to the function directly and thus make the query more readable by
putting it in context.
Refs #5889
| -rw-r--r-- | app/controllers/autocomplete_lines_controller.rb | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/app/controllers/autocomplete_lines_controller.rb b/app/controllers/autocomplete_lines_controller.rb index 0202ea054..6f5009390 100644 --- a/app/controllers/autocomplete_lines_controller.rb +++ b/app/controllers/autocomplete_lines_controller.rb @@ -8,15 +8,12 @@ class AutocompleteLinesController < ChouetteController def collection @lines = referential.line_referential.lines - filter = <<~SQL - lines.number LIKE ? - OR lines.name LIKE ? - OR companies.name ILIKE ? - SQL @lines = @lines .joins(:company) - .where( - filter, + .where(' + lines.number LIKE ? + OR lines.name LIKE ? + OR companies.name ILIKE ?', *Array.new(3, "%#{params[:q]}%") ) .search(params[:q]) |
