To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.

Statistics Download as Zip
| Branch: | Tag: | Revision:

root / app / controllers / auto_completes_controller.rb @ 440:6253d777aa12

History | View | Annotate | Download (665 Bytes)

1
class AutoCompletesController < ApplicationController
2
  before_filter :find_project
3
  
4
  def issues
5
    @issues = []
6
    q = params[:q].to_s
7
    if q.match(/^\d+$/)
8
      @issues << @project.issues.visible.find_by_id(q.to_i)
9
    end
10
    unless q.blank?
11
      @issues += @project.issues.visible.find(:all, :conditions => ["LOWER(#{Issue.table_name}.subject) LIKE ?", "%#{q.downcase}%"], :limit => 10)
12
    end
13
    render :layout => false
14
  end
15

    
16
  private
17

    
18
  def find_project
19
    project_id = (params[:issue] && params[:issue][:project_id]) || params[:project_id]
20
    @project = Project.find(project_id)
21
  rescue ActiveRecord::RecordNotFound
22
    render_404
23
  end
24

    
25
end