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?
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]
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.