Forum: Ferret acts_as_ferret choking

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Samuel Kvarnbrink (Guest)
on 2006-05-10 16:18
(Received via mailing list)
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:

> acts_as_ferret/lib/acts_as_ferret.rb:470:in `latest?'
> 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: removed_email_address@domain.invalid
blog:  http://samuelk.info


"I once had a problem.
  I thought: "Oh, I know: I'll just use XML!"

  Now I had two problems."
Kasper W. (Guest)
on 2006-05-10 17:30
Hi Samuel

This is beeing discussed under ticket #6 on the aaf trac
http://projects.jkraemer.net/acts_as_ferret/ticket/6

A fair number of test problems with aaf has been resolved with the newly
released ferret 0.9.2 and the trunk version of aaf but I haven't had
time to check for this problem.

Kasper

Samuel Kvarnbrink wrote:
> 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:
>
>> acts_as_ferret/lib/acts_as_ferret.rb:470:in `latest?'
>> 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: removed_email_address@domain.invalid
> blog:  http://samuelk.info
>
>
> "I once had a problem.
>   I thought: "Oh, I know: I'll just use XML!"
>
>   Now I had two problems."
This topic is locked and can not be replied to.