I'm Co-Founder & CTO of BlockAvenue. , connect with me, or subscribe.

Beware using active_admin and Sunspot Rails gems together

If you are using Active Admin and the Sunspot gem for Rails, beware: they conflict on the search method leading to some very confusing results.

Active Admin has a dependency on meta_search which provides a .search() method on Active Record classes. Sunspot attempts to provide the same method, aliased from solr_search, but only if the method does not already exist.

In short, searching can be done using solr_search() rather than search():

1
2
3
4
5
6
@search = Profile.solr_search do
  keywords params[:q]
  paginate page: params[:page], per_page: page_size
end

@results = @search.results