Mercurial > hg > soundsoftware-site
view app/controllers/auto_completes_controller.rb @ 774:58410c63bb84 feature_334
Force a Google search box rudely into the middle of the search view, just to see how it looks.
It can be styled reasonably well -- but the adverts, when they appear, are atrocious.
author | Chris Cannam <chris.cannam@soundsoftware.ac.uk> |
---|---|
date | Thu, 17 Nov 2011 14:56:55 +0000 |
parents | af80e5618e9b |
children | cbb26bc654de |
line wrap: on
line source
class AutoCompletesController < ApplicationController before_filter :find_project def issues @issues = [] q = params[:q].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) 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) rescue ActiveRecord::RecordNotFound render_404 end end