Default scope with Sunspot

Posted on by Tim Rosenblatt

While I was DRYing up some code, I noticed that a lot of my Sunspot searches were using the same options over and over. Default scope is a nice option in ActiveRecord queries, why not in our searches?

This way you can specify your search options in the Sunspot DSL from each method, while moving repetitive options to a single location. Clean, readable, and effective.

Great props to Mr Mat for his help

 
comments powered by Disqus