Skip to content

Instantly share code, notes, and snippets.

@richmolj
Last active December 18, 2015 16:29
Show Gist options
  • Save richmolj/5811237 to your computer and use it in GitHub Desktop.
Save richmolj/5811237 to your computer and use it in GitHub Desktop.
class Post
def search(keywords)
search = Sunspot.search(Post) do
fulltext keywords
order_by :published_at, :desc if Configuration.post_ordering?
end
end
CustomAlarmHandler.new(:post_search).raise('empty!') if search.results.empty?
StatsCollector.register_event(:post_search, keywords)
search.results
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment