aboutsummaryrefslogtreecommitdiffstats
path: root/app/controllers/autocomplete_lines_controller.rb
diff options
context:
space:
mode:
authorTeddy Wing2018-02-26 14:45:58 +0100
committerJohan Van Ryseghem2018-03-07 13:19:41 +0100
commitf372eda831e91da367007f3e0aef725c6a67c574 (patch)
treee3d22c00c4c65ab4e7e53d2b0a00e4578c8d8ec1 /app/controllers/autocomplete_lines_controller.rb
parentf43442404d37cfb04b012c73c24b1dc4bf01168d (diff)
downloadchouette-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
Diffstat (limited to 'app/controllers/autocomplete_lines_controller.rb')
-rw-r--r--app/controllers/autocomplete_lines_controller.rb11
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])