Hey Pat, Thanks for the quick response!
I'm using Rails 2.2.2 Calling ThinkingSphinx::Configuration.instance.load_models throws a NoMethodeError, but I seem to get the right behavior by calling the following in environments/development.rb config.after_initialize do ThinkingSphinx::Configuration.new.load_models end Does this create an additional ThinkingSphinx::Configuration instance (along with an additional Riddle etc instance) for each request? It's noticable slower when starting script/console, but I don't really mind as long as it works properly. Is ThinkingSphinx::Configuration.instance in a newer version of the plugin? I'll look now. Anyway this is essentially resolved and things work fine in production mode, so thanks for the help!! On Dec 26, 8:23 am, Pat Allan <[email protected]> wrote: > 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 -~----------~----~----~----~------~----~------~--~---
