Skip to content

Instantly share code, notes, and snippets.

@bsy
Created August 21, 2009 16:12
Show Gist options
  • Save bsy/172147 to your computer and use it in GitHub Desktop.
Save bsy/172147 to your computer and use it in GitHub Desktop.
def nationwide_search
category_ids = self.category_ids
Business.search do |search|
search.any_of do
with :category_ids, category_ids unless category_ids.blank?
with :category_ids, nil
end
search.keywords query
search.order_by :name if order == :alpha
search.order_by :review_count, :desc if order == :review_count
search.order_by :stars, :desc if order == :rating
search.paginate :page => page, :per_page => per_page
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment