Class: MerbSearch::Search

Inherits:
Application
  • Object
show all
Defined in:
app/controllers/search.rb

Instance Method Summary collapse

Instance Method Details

#indexObject



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'app/controllers/search.rb', line 3

def index

  if @query = params[:q] and !@query.blank?

    images = boss.images.new(@query, :count => 3)
    @images = images.resultset unless images.count == 0

    news = boss.news.new(@query, :age => '1d', :count => 3)
    @news = news.resultset unless news.count == 0

    spelling = boss.spelling.new(@query)
    @spelling = spelling.resultset unless spelling.count == 0
    
    web_count = 12 - (images.count + news.count)
    web = boss.web.new(@query, :count => web_count)
    @web = web.resultset unless web.count == 0
    
    keyterms = boss.web.new(@query, :count => 1, :view => 'keyterms')
    @keyterms = keyterms.resultset[0].keyterms unless keyterms.count == 0
    
  end

  render

end