Web Development

I needed code where there would be a dynamic number of terms to search a single field. Here’s the code I used.

StackOverflow pages (didn’t work for me):

Non-StackOverflow (didn’t work for me, but still helpful)

  def self.search_by_location(terms)
    terms = terms.split(',')
    where(('facilities.name=? ' * terms.count).split(' ').join(' OR '), *terms)
  end