Hi Alex What version of Rails are you using? Seems like Thinking Sphinx isn't aware of all the models when the app loads - which is normal for Rails in development mode usually, but TS cheats and loads all models when starting the server (or console). Different versions of Rails treat this differently though, so it's not always reliable.
A work-around is to add the following line to the end of your environment.rb file: ThinkingSphinx::Configuration.instance.load_models Cheers -- Pat On 26/12/2008, at 7:01 PM, Alex Caudill wrote: > As an update, calling ThinkingSphinx::Search#search_for_ids works > fine. > > >> ThinkingSphinx::Search.search_for_ids "membername" > => [3] > > Whereas calling User#search_for_ids doesn't work properly (unless > User.find(3) or another #find call with 3 among the results has been > called before). > > >> User.search_for_ids "membername" > => [] > > Any ideas? > > On Fri, Dec 26, 2008 at 5:13 AM, Alex Caudill <[email protected]> > wrote: > Please ignore the inconsistent User/Individual class names, I was > trying to simplify the examples and probably ended up making it a > bit more confusing... > > Long story short, I need to have done a successful #find on any > given model instance before ThinkingSphinx will successfully return > it with #search. > > On Fri, Dec 26, 2008 at 4:50 AM, Alex <[email protected]> wrote: > > Hi, > > Firstly, thinking sphinx is great ;) > > I'm having some trouble working with it in development mode. Here's > the behavior I'm getting: > > a...@railsdev:~/myproject$ script/console > Loading development environment (Rails 2.2.2) > >> User.search :conditions => { :member => "membername" } > => [] > > Initially the search returns nothing, which is weird, because I know > membername exists. Let's confirm this. > > >> User.find_by_name("erudified") > => #<User id: 3, email: "mem...@member", name: "membername", > (attributes chopped for brevity)> > > >> User.find(:all) > (bunch of users) > > And now after calling User.find(:all) (or simply #find_by_name, either > works) in development mode, User#search works as expected... > > >> User.search :conditions => { :member => "erudified" } > => [#<Individual id: 3, email: "mem...@member", name: "membername", > (attributes chopped for brevity)>] > > How can I prevent this behavior? Any advice would be appreciated! > > > > > > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
