Module: Refinery::SearchHelper

Defined in:
app/helpers/refinery/search_helper.rb

Instance Method Summary collapse

Instance Method Details

#result_title(result) ⇒ Object



4
5
6
# File 'app/helpers/refinery/search_helper.rb', line 4

def result_title(result)
  result.title.gsub /(#{Regexp.escape(params[:query])})/i, '<mark>\1</mark>'
end

#result_type(result) ⇒ Object



8
9
10
11
12
13
14
# File 'app/helpers/refinery/search_helper.rb', line 8

def result_type(result)
  if result.class.method_defined?(:friendly_search_name)
    result.friendly_search_name
  else
    result.class.to_s.titleize.split("/").last
  end
end

#result_url(result) ⇒ Object

this is where you register your result URLs based on the type of result we’re dealing with



18
19
20
21
22
23
24
# File 'app/helpers/refinery/search_helper.rb', line 18

def result_url(result)
  if result.respond_to? :url
    refinery.url_for result.url
  else
    refinery.url_for send(Refinery.route_for_model(result.class, :admin => false), result)
  end
end