Typo and acts_as_ferret rebuild_index errror

Hi, I’m running the edge Typo and the latest acts_as_ferret plugin and
ferret gems (as of 11 April).

In my Content model I put acts_as_ferret :fields => [:title, :body]

In the console, I call Content.rebuild_index to index all of my existing
content. All the directories get created etc, but I get the following
error back:

Loading development environment.

Content.rebuild_index
NameError: undefined method title' for classComment’
from
./script/…/config/…/config/…/vendor/plugins/acts_as_ferret/lib/a
cts_as_ferret.rb:104:in method' from ./script/../config/../config/../vendor/plugins/acts_as_ferret/lib/a cts_as_ferret.rb:104:intitle_to_ferret’
from
./script/…/config/…/config/…/vendor/plugins/acts_as_ferret/lib/a
cts_as_ferret.rb:103:in title_to_ferret' from ./script/../config/../config/../vendor/plugins/acts_as_ferret/lib/a cts_as_ferret.rb:439:insend’
from
./script/…/config/…/config/…/vendor/plugins/acts_as_ferret/lib/a
cts_as_ferret.rb:439:in to_doc' from ./script/../config/../config/../vendor/plugins/acts_as_ferret/lib/a cts_as_ferret.rb:438:ineach’
from
./script/…/config/…/config/…/vendor/plugins/acts_as_ferret/lib/a
cts_as_ferret.rb:438:in to_doc' from ./script/../config/../config/../vendor/plugins/acts_as_ferret/lib/a cts_as_ferret.rb:217:inrebuild_index’
from
./script/…/config/…/config/…/vendor/plugins/acts_as_ferret/lib/a
cts_as_ferret.rb:217:in each' from ./script/../config/../config/../vendor/plugins/acts_as_ferret/lib/a cts_as_ferret.rb:217:inrebuild_index’
from (irb):1

Has anybody got this to work before?

Thanks
Joerg

I’m not exactly sure why the error is about an undefined method for the
class Comment, when you run rebuild_index on Content.

  1. Does Comment have the fields ‘title’ and ‘body’ defined somewhere?
  2. Didn’t you mean Comment.rebuild_index?

Joerg D. wrote:

In my Content model I put acts_as_ferret :fields => [:title, :body]
Loading development environment.

Content.rebuild_index
NameError: undefined method title' for classComment’
from
./script/…/config/…/config/…/vendor/plugins/acts_as_ferret/lib/a
cts_as_ferret.rb:104:in `method’

Sorry - I wasn’t clear enough. Comment is defined as:

class Comment < Content

and

class Content < ActiveRecord::Base

The contents table has fields like title, body, extended etc … so the
Comment model will have them too then. The error isn’t particular to the
:title field either … if I were to have :extended as part of the
fields list, it’ll through the same error but wrt extended.

Kasper W. wrote:

I’m not exactly sure why the error is about an undefined method for the
class Comment, when you run rebuild_index on Content.

  1. Does Comment have the fields ‘title’ and ‘body’ defined somewhere?
  2. Didn’t you mean Comment.rebuild_index?

Joerg D. wrote:

In my Content model I put acts_as_ferret :fields => [:title, :body]
Loading development environment.

Content.rebuild_index
NameError: undefined method title' for classComment’
from
./script/…/config/…/config/…/vendor/plugins/acts_as_ferret/lib/a
cts_as_ferret.rb:104:in `method’

I can test it … do I just get the latest acts_as_ferret.rb file?
http://www.jkraemer.net/files/acts_as_ferret.rb

Jens K. wrote:

Hi,

I could reproduce the error, but I can’t explain why it happens :wink:
I just committed a fix that rescues from the failure and indexes an
empty string for the field in question.

That’s an old location. Try here instead (or use SVN)
http://projects.jkraemer.net/acts_as_ferret/browser/trunk/plugin/acts_as_ferret/lib/acts_as_ferret.rb?format=raw

Joerg D. wrote:

I can test it … do I just get the latest acts_as_ferret.rb file?
http://www.jkraemer.net/files/acts_as_ferret.rb

Jens K. wrote:

Hi,

I could reproduce the error, but I can’t explain why it happens :wink:
I just committed a fix that rescues from the failure and indexes an
empty string for the field in question.

Ok got it thanks. Tried it out. Error is gone. Return value from
rebuild_index is false. Is that right?

Kasper W. wrote:

That’s an old location. Try here instead (or use SVN)
http://projects.jkraemer.net/acts_as_ferret/browser/trunk/plugin/acts_as_ferret/lib/acts_as_ferret.rb?format=raw

According to the API false is the correct value
http://ferret.davebalmain.com/api/classes/Ferret/Index/Index.html#M000041

Joerg D. wrote:

Ok got it thanks. Tried it out. Error is gone. Return value from
rebuild_index is false. Is that right?

Hi,

I could reproduce the error, but I can’t explain why it happens :wink:
I just committed a fix that rescues from the failure and indexes an
empty string for the field in question.

It seems the errors are raised when aaf tries to index a
field that isn’t used by the particular model class, i.e. :title in a
Comment object.

Could you please try if the change fixes this for you, too ?

Greetings,
Jens

On Thu, Apr 13, 2006 at 08:13:03PM +0200, Joerg D. wrote:

:title field either … if I were to have :extended as part of the


Posted via http://www.ruby-forum.com/.


Ferret-talk mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/ferret-talk


webit! Gesellschaft für neue Medien mbH www.webit.de
Dipl.-Wirtschaftsingenieur Jens Krämer [email protected]
Schnorrstraße 76 Tel +49 351 46766 0
D-01069 Dresden Fax +49 351 46766 66

K great. Well - I tested it by doing searches, and my content was
correctly indexed.

Thanks a lot for your help!

Joerg

Kasper W. wrote:

According to the API false is the correct value
http://ferret.davebalmain.com/api/classes/Ferret/Index/Index.html#M000041

Joerg D. wrote:

Ok got it thanks. Tried it out. Error is gone. Return value from
rebuild_index is false. Is that right?

On Mon, Apr 17, 2006 at 07:51:07PM +0200, Joerg D. wrote:

K great. Well - I tested it by doing searches, and my content was
correctly indexed.

Thanks a lot for your help!

glad to help :slight_smile:

Jens


webit! Gesellschaft für neue Medien mbH www.webit.de
Dipl.-Wirtschaftsingenieur Jens Krämer [email protected]
Schnorrstraße 76 Tel +49 351 46766 0
D-01069 Dresden Fax +49 351 46766 66

Jens K. wrote:

I could reproduce the error, but I can’t explain why it happens :wink:
I just committed a fix that rescues from the failure and indexes an
empty string for the field in question.

It seems the errors are raised when aaf tries to index a
field that isn’t used by the particular model class, i.e. :title in a
Comment object.

I was seeing a similar error on cases where there would be a
single row that had NULL for the value of an indexed field. Rows
before that row would index and then the exception would be
encountered and indexing would stop.

This fix also works for me.

Thanks,

Ray