Rails fans are familiar with params[:terms]
or a hash of 'things' passed to the controller collected form the url. E.g.:
params
=> {"term"=>"Warren Buffet",
"controller"=>"search",
"format"=>"json",
"action"=>"index"}
If I want to use "Warren Buffet", "Warren" and "Buffet" in the code below, does anyone know which method I should be using instead? gsub
is close, but it takes each match and not the original string too. Unless I'm doing it wrong, which is totally possible:
@potential_investors = [] params[:term].gsub(/(\w{1,})/) do |term| @potential_investors << User.where(:investor => true) .order('first_name ASC, last_name ASC') .search_potential_investors(term) end
Thoughts?