Hi all,
I''ve ran into a problem with Ferret on my rails app, and I
don''t
really have a clue about why. When running the unit tests, I get the
following error output:
> Exception raised:
> Class: <NoMethodError>
> Message: <"You have a nil object when you didn''t expect
it!\nThe
> error occured while evaluating nil.version">
> ---Backtrace---
> /opt/local/lib/ruby/gems/1.8/gems/ferret-0.9.1/lib/ferret/index/
> index_reader.rb:365:in `latest?''
> /Users/sk/Documents/svn/cms/branches/nodes/vendor/plugins/
> acts_as_ferret/lib/acts_as_ferret.rb:470:in `latest?''
> /Users/sk/Documents/svn/cms/branches/nodes/vendor/plugins/
> acts_as_ferret/lib/acts_as_ferret.rb:470:in `latest?''
> /opt/local/lib/ruby/gems/1.8/gems/ferret-0.9.1/lib/ferret/index/
> index.rb:635:in `ensure_reader_open''
> /opt/local/lib/ruby/gems/1.8/gems/ferret-0.9.1/lib/ferret/index/
> index.rb:650:in `ensure_searcher_open''
> /opt/local/lib/ruby/gems/1.8/gems/ferret-0.9.1/lib/ferret/index/
> index.rb:390:in `query_delete''
> /opt/local/lib/ruby/1.8/monitor.rb:229:in `synchronize''
> /opt/local/lib/ruby/gems/1.8/gems/ferret-0.9.1/lib/ferret/index/
> index.rb:389:in `query_delete''
> /opt/local/lib/ruby/gems/1.8/gems/ferret-0.9.1/lib/ferret/index/
> index.rb:293:in `<<''
> /opt/local/lib/ruby/1.8/monitor.rb:229:in `synchronize''
> /opt/local/lib/ruby/gems/1.8/gems/ferret-0.9.1/lib/ferret/index/
> index.rb:258:in `<<''
> /Users/sk/Documents/svn/cms/branches/nodes/vendor/plugins/
> acts_as_ferret/lib/acts_as_ferret.rb:407:in `ferret_update''
> (...)
The problem seems to be caused by the following code in acts_as_ferret:
@sub_readers.each { |r| return false unless r.latest? }
which, in turn, causes a NoMethodError because @segment_infos is nil.
The problem (or, at least, the symptom) goes away when I add a rescue
clause inside the block that gets passed to @sub_readers.each, but it
feels like a bad way of solving it. Anyone who knows why this happens
in the first place? And what should I do to avoid it?
//samuel
_______________________
Samuel Kvarnbrink
mail: samuel.kvarnbrink at minervaskolan.se
blog: http://samuelk.info
"I once had a problem.
I thought: "Oh, I know: I''ll just use XML!"
Now I had two problems."