annotate app/controllers/auto_completes_controller.rb @ 45:65d9e2cabaa3 luisf

Added tipoftheday to the config/settings in order to correct previous issues. Tip of the day is now working correctly. Added the heading strings to the locales files.
author luisf
date Tue, 23 Nov 2010 11:50:01 +0000
parents 1d32c0a0efbf
children af80e5618e9b
rev   line source
Chris@14 1 class AutoCompletesController < ApplicationController
Chris@14 2 before_filter :find_project
Chris@14 3
Chris@14 4 def issues
Chris@14 5 @issues = []
Chris@14 6 q = params[:q].to_s
Chris@14 7 if q.match(/^\d+$/)
Chris@14 8 @issues << @project.issues.visible.find_by_id(q.to_i)
Chris@14 9 end
Chris@14 10 unless q.blank?
Chris@14 11 @issues += @project.issues.visible.find(:all, :conditions => ["LOWER(#{Issue.table_name}.subject) LIKE ?", "%#{q.downcase}%"], :limit => 10)
Chris@14 12 end
Chris@14 13 render :layout => false
Chris@14 14 end
Chris@14 15
Chris@14 16 private
Chris@14 17
Chris@14 18 def find_project
Chris@14 19 project_id = (params[:issue] && params[:issue][:project_id]) || params[:project_id]
Chris@14 20 @project = Project.find(project_id)
Chris@14 21 rescue ActiveRecord::RecordNotFound
Chris@14 22 render_404
Chris@14 23 end
Chris@14 24
Chris@14 25 end