Module: SearchHelper

Defined in:
app/helpers/search_helper.rb

Instance Method Summary collapse

Instance Method Details



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

def focus_search_link text, search_class, query
  search_class = search_class.to_s if search_class.is_a? Class or search_class.is_a? Symbol
  link_to text, search_path(:focus => search_class.downcase.pluralize, :search_query => query ), :remote => true
end

#get_search_query_wordsObject



33
34
35
36
37
# File 'app/helpers/search_helper.rb', line 33

def get_search_query_words
  search_query = ""
  bare_query = strip_tags(params[:search_query]) unless bare_query.html_safe?
  return bare_query.strip.split
end

#model_with_details(model) ⇒ Object



22
23
24
# File 'app/helpers/search_helper.rb', line 22

def model_with_details model
  render_model_view model, "_with_details"
end

#render_focus_search_for(model) ⇒ Object



18
19
20
# File 'app/helpers/search_helper.rb', line 18

def render_focus_search_for model
  render_model_view model, "_focus_search"    
end

#render_global_search_for(model) ⇒ Object



14
15
16
# File 'app/helpers/search_helper.rb', line 14

def render_global_search_for model
  render_model_view model, "_global_search"    
end

#render_model_view(model, type) ⇒ Object



26
27
28
29
30
31
# File 'app/helpers/search_helper.rb', line 26

def render_model_view model, type
  model = model.model if model.is_a? Actor    
  render :partial => model.class.to_s.pluralize.downcase + '/' + model.class.to_s.downcase + type,
         :locals => {model.class.to_s.downcase.to_sym => model}
  
end

#too_short_query?Boolean

Returns:

  • (Boolean)


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

def too_short_query?
  return true if params[:search_query].blank?
  bare_query = strip_tags(params[:search_query]) unless bare_query.html_safe?
  return bare_query.strip.size < SearchController::MIN_QUERY
end