08 August 2015

Ransack namespace collision - The search method

I am a big fan of Ransack, the Rails gem for quickly building a quick and easy Search based on pure ActiveRecord queries. For projects that require some on the fly search without having to set up dedicated Search Engines like Elastic Search, SOLR, ThinkinSphinx - this is a very juicy alternative.

However I recently faced one problem when I introduced this to a project where there already was SOLR integrated. It was because of the collision of the search method.

This simply patch did the job for me. All you have to do is include it to your initializers folder say under config/initializers/ransack.rb

That's it, the Ransack library will no longer collide with your existing suite. As a matter of fact the method search deprecated already and the library itself wants us to use the Alias ransack

Cheers!
Braga

No comments: