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? }