1
0
mirror of https://github.com/meineerde/redmine.git synced 2025-12-19 15:01:14 +00:00

Adds a scope for issue auto complete.

git-svn-id: http://svn.redmine.org/redmine/trunk@16245 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang 2017-01-21 10:05:53 +00:00
parent 30493d5421
commit c283212f9f
2 changed files with 7 additions and 1 deletions

View File

@ -35,7 +35,7 @@ class AutoCompletesController < ApplicationController
@issues << scope.find_by_id($1.to_i)
end
@issues += scope.where("LOWER(#{Issue.table_name}.subject) LIKE LOWER(?)", "%#{q}%").order(:id => :desc).limit(10).to_a
@issues += scope.like(q).order(:id => :desc).limit(10).to_a
@issues.compact!
end
render :layout => false

View File

@ -98,6 +98,12 @@ class Issue < ActiveRecord::Base
ids.compact!
ids.any? ? where(:assigned_to_id => ids) : none
}
scope :like, lambda {|q|
q = q.to_s
if q.present?
where("LOWER(#{table_name}.subject) LIKE LOWER(?)", "%#{q}%")
end
}
before_validation :clear_disabled_fields
before_create :default_assign