Ok, this isn't just a Rails caching issue (although that needs to be
addressed). Debugging this raised even more bizarre results. Remember,
this code worked perfectly prior to Pat's refactoring of
TS::Collection => TS::Search

Suppose you have this code:

        temp_a = sphinx.search_for_ids(self.q)
        temp_b = temp_a.results
        sphinx_ids, sphinx_response = [temp_a, temp_b]

If you check the values after this code has run(via debugger), you
will have something like sphinx_ids = [1,2,3,...] but
temp_b  and sphinx_response will be nil.

However, if you call temp_a.results manually while debugging you will
get the hash of result values just like you expect. So basically, if
you let the code above run on its own, temp_b = nil. However, if you
manually enter the code into console while the code is being debugged,
it works properly and returns the hash of results.

Does anyone have any ideas as to what might cause this? I am beginning
to think this is a naming issue. The model that I use to setup and run
the search is called "Search".

I would greatly appreciate any insight as this isn't making much sense
to me at the moment. I am not used to code that works in the console
but doesn't work when ran normally.

Thanks,

DrMark

On Aug 7, 4:39 pm, DrMark <[email protected]> wrote:
> Aloha everyone,
>
> I just encountered a very odd bug in TS. First, the code that is
> throwing the error has been working perfectly up to this point. The
> error started after I upgraded to the latest version of TS where Pat
> changed the ThinkingSphinx::Collection code to
> ThinkingSphinx::Search.
>
> The bug happens when you use Rails caching.
>
> If you have something like this:
>
> sphinx_ids = Rails.cache.fetch(%Q!#{search_string}!)
> { sphinx.search_for_ids q, :with => filters, :order => opts
> [:order], :include => opts[:include] }
>
> This returns a valid ThinkingSphinx::Search object the first time. On
> all subsequent calls, however it returns an Array. Thus, any calls to
> TS methods (like results) will bomb.
>
> I haven't yet had the time to dig through this to find the cause. Does
> anyone have an idea why Rails.cache.fetch worked fine with the old
> TS::Collection code but bombs with the new TS::Search code?
>
> Thanks!
>
> DrMark
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Thinking Sphinx" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/thinking-sphinx?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to