Hi, I'm just getting starting with Thinking Sphinx and I love it so
far! I was having a problem with some rake tasks that depend on the
environment task (there are lots of these) where the thinking_sphinx
gem wasn't loading and so any model that used it was raising a
MethodNotFound error on #define_index when loading.

I had configured thinking_sphinx in config/environment.rb as
recommended:
  config.gem 'freelancing-god-thinking-sphinx', :lib =>
'thinking_sphinx'

But after investigating the problem I think that for these tasks this
was only configuring a dependency, not loading the gem. I'm not sure
why.

My solution was to require 'thinking_sphinx' as well as
'thinking_sphinx/tasks' in my Rakefile to force it to load:
 require 'thinking_sphinx'
 require 'thinking_sphinx/tasks'

I wonder if anyone else has seen this? Or if anyone can suggest
something I'm doing wrong?

Here's an easy way to reproduce it with rails 2.3.2 and thinking-
sphinx 1.1.20.

1. Create a rake task in lib/tasks like the following:

 task 'dependency_test' => :environment do
   Document # replace this with any model that calls #define_index
 end

2. Then run the task:

a...@ahlx:~/devel/test$ rake dependency_test
(in /home/ajh/devel/test)
rake aborted!
undefined method `define_index' for #<Class:0xb5a824b4>

(See full trace by running task with --trace)

3. Add "require 'thinking_sphinx'" before the require for
'thinking_sphinx/tasks' (as described above) in your Rakefile and
observe that it fixes the problem.

Thanks,
Andy

--~--~---------~--~----~------------~-------~--~----~
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