Have you ever gotten a result like the following when using ThinkingSphinx (by the awesome Pat Allen):
NoMethodError (undefined method `constantize' for nil:NilClass):
This error occurs when your index isn’t quite up to date and ThinkingSphinx returns results that have since been deleted from your database. To fix the problem add
:retry_stale => true
to your searches, like this:Article.search('chunky bacon', :retry_stale => true)
There is more information about
:retry_stale
in the source code:# If you pass :retry_stale => true to a single-model search, missing records will
# cause Thinking Sphinx to retry the query but excluding those records. Since search
# is paginated, the new search could potentially include missing records as well, so by
# default Thinking Sphinx will retry three times. Pass :retry_stale => 5 to retry five
# times, and so on. If there are still missing ids on the last retry, they are
# shown as nils.
No comments:
Post a Comment