From fe9ac9422290b45266488fa09f21d13fc943c761 Mon Sep 17 00:00:00 2001 From: Jasder <2053003901@@qq.com> Date: Thu, 19 Mar 2020 17:15:56 +0800 Subject: [PATCH] FIX search projects relation repository --- app/models/concerns/matchable.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/concerns/matchable.rb b/app/models/concerns/matchable.rb index cd7b7e2..13fcff8 100644 --- a/app/models/concerns/matchable.rb +++ b/app/models/concerns/matchable.rb @@ -3,7 +3,7 @@ module Matchable included do scope :like, lambda { |keywords| - where("name LIKE ?", "%#{keywords.split(" ").join('|')}%") unless keywords.blank? + joins(:repository).where(%w[ projects.name projects.identifier repositories.identifier ].map { |f| "LOWER(#{f}) LIKE :q" }.join(' OR '), q: "%#{keywords.split(" ").join('|')}%") unless keywords.blank? } scope :with_project_category, ->(category_id) { where(project_category_id: category_id) unless category_id.blank? } scope :with_project_language, ->(language_id) { where(project_language_id: language_id) unless language_id.blank? }