summaryrefslogtreecommitdiffstats
path: root/app/controllers
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2012-08-09 16:43:12 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2012-08-09 16:43:12 +0000
commit908b960e7181680cc180ab3d07921fc9977a39db (patch)
treee41609d7468c7164cf2d02e8570646ecd4a355cd /app/controllers
parent0ce0b52342dfb5fd6c444609ef0370f7fdd28230 (diff)
downloadredmine-908b960e7181680cc180ab3d07921fc9977a39db.tar.gz
redmine-908b960e7181680cc180ab3d07921fc9977a39db.zip
Code cleanup.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@10180 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/auto_completes_controller.rb20
1 files changed, 9 insertions, 11 deletions
diff --git a/app/controllers/auto_completes_controller.rb b/app/controllers/auto_completes_controller.rb
index 203dae4e7..1bbcd33f8 100644
--- a/app/controllers/auto_completes_controller.rb
+++ b/app/controllers/auto_completes_controller.rb
@@ -20,25 +20,23 @@ class AutoCompletesController < ApplicationController
def issues
@issues = []
- q = (params[:q] || params[:term]).to_s
- query = (params[:scope] == "all" && Setting.cross_project_issue_relations?) ? Issue : @project.issues
- if q.match(/^\d+$/)
- @issues << query.visible.find_by_id(q.to_i)
+ q = (params[:q] || params[:term]).to_s.strip
+ if q.present?
+ scope = (params[:scope] == "all" ? Issue : @project.issues).visible
+ if q.match(/^\d+$/)
+ @issues << scope.find_by_id(q.to_i)
+ end
+ @issues += scope.where("LOWER(#{Issue.table_name}.subject) LIKE ?", "%#{q.downcase}%").order("#{Issue.table_name}.id DESC").limit(10).all
+ @issues.compact!
end
- unless q.blank?
- @issues += query.visible.find(:all, :conditions => ["LOWER(#{Issue.table_name}.subject) LIKE ?", "%#{q.downcase}%"], :limit => 10)
- end
- @issues.compact!
render :layout => false
end
private
def find_project
- project_id = (params[:issue] && params[:issue][:project_id]) || params[:project_id]
- @project = Project.find(project_id)
+ @project = Project.find(params[:project_id])
rescue ActiveRecord::RecordNotFound
render_404
end
-
end