2

I included thinking_sphinx gem in my project.

Article.search "Bla-bla-bla" works fine.

But when I include ransack gem in my Gemfile I get the error:

NoMethodError: undefined method `with_indifferent_access' for "Bla-bla-bla":String from /Users/ashvalev/.rvm/gems/ruby-1.9.2-p290/gems/ransack-0.7.2/lib/ransack/search.rb:21:in `initialize'

It is because ransack gem also uses name "search" for its searching method.

What can I do to make these gems work together?

Aleksandr Shvalev
  • 1,005
  • 2
  • 11
  • 22

2 Answers2

0

The solution is to call ThinkingSphinx.search instead of the specific model's #search method.

Instead of

Article.search "Bla-bla-blah"

Use the system-wide search call, but constrain to the class...

ThinkingSphinx.search "Bla-Bla-Blah", classes: [Article]
Michael Lang
  • 1,028
  • 12
  • 21
0

You'll want to list ransack before thinking-sphinx in your Gemfile - the load order matters.

Though I would certainly recommend just using one of the two when it comes to searches.

pat
  • 16,116
  • 5
  • 40
  • 46