Class: SearchController

Inherits:
ApplicationController show all
Defined in:
app/controllers/search_controller.rb

Constant Summary

Constants included from Localization

Localization::LOCALIZED_STRINGS

Instance Method Summary collapse

Methods inherited from ApplicationController

in_place_edit_for, #initialize

Methods included from ApplicationHelper

#back_or_link_to, #detour?, #detour_to, #display_notice, #h, #image_button_to, #image_detour_to, #image_link_to, #image_link_to_remote, #insert, #record, #resolution_image, #t, #update_task, #with_detour

Methods included from Localization

#l, load_localized_strings, #valid_language?

Constructor Details

This class inherits a constructor from ApplicationController

Instance Method Details

#resultsObject



3
4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'app/controllers/search_controller.rb', line 3

def results
  if params[:q]
    @search = params[:q]
    @backlogs = Backlog.find(:all, :conditions => ["lower(name) LIKE ?", "%#{@search.downcase}%"])
    @tasks = Task.find(:all, :conditions => ["lower(description) LIKE ? OR lower(notes) LIKE ?", "%#{@search.downcase}%", "%#{@search.downcase}%"])
    @work_accounts = WorkAccount.find(:all, :conditions => ["lower(name) LIKE ?", "%#{@search.downcase}%"])
    @works = Work.find(:all, :conditions => ["lower(description) LIKE ? OR lower(notes) LIKE ?", "%#{@search.downcase}%", "%#{@search.downcase}%"])
  else
    @backlogs = []
    @tasks = []
    @work_accounts = []
    @works = []
  end
end