Forum: Ferret Typo and acts_as_ferret rebuild_index errror

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.
Joerg D. (Guest)
on 2006-04-13 19:57
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 class `Comment'
        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:in `title_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:in `send'
        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:in `each'
        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:in `rebuild_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:in `rebuild_index'
        from (irb):1
>>


Has anybody got this to work before?

Thanks
Joerg
Kasper W. (Guest)
on 2006-04-13 20:31
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 class `Comment'
>         from
> ./script/../config/../config/../vendor/plugins/acts_as_ferret/lib/a
> cts_as_ferret.rb:104:in `method'
Joerg D. (Guest)
on 2006-04-13 22:13
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 class `Comment'
>>         from
>> ./script/../config/../config/../vendor/plugins/acts_as_ferret/lib/a
>> cts_as_ferret.rb:104:in `method'
Jens K. (Guest)
on 2006-04-17 19:54
(Received via mailing list)
Hi,

I could reproduce the error, but I can't explain why it happens ;-)
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
> removed_email_address@domain.invalid
> http://rubyforge.org/mailman/listinfo/ferret-talk

--
webit! Gesellschaft für neue Medien mbH          www.webit.de
Dipl.-Wirtschaftsingenieur Jens Krämer 
removed_email_address@domain.invalid
Schnorrstraße 76                         Tel +49 351 46766  0
D-01069 Dresden                          Fax +49 351 46766 66
Joerg D. (Guest)
on 2006-04-17 20:18
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 ;-)
> I just committed a fix that rescues from the failure and indexes an
> empty string for the field in question.
Kasper W. (Guest)
on 2006-04-17 20:39
That's an old location. Try here instead (or use SVN)
http://projects.jkraemer.net/acts_as_ferret/browse...


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 ;-)
>> I just committed a fix that rescues from the failure and indexes an
>> empty string for the field in question.
Joerg D. (Guest)
on 2006-04-17 20:57
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/browse...
>
>
Kasper W. (Guest)
on 2006-04-17 21:08
According to the API false is the correct value
http://ferret.davebalmain.com/api/classes/Ferret/I...


Joerg D. wrote:
> Ok got it thanks. Tried it out. Error is gone. Return value from
> rebuild_index is false. Is that right?
>
Joerg D. (Guest)
on 2006-04-17 21:51
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/I...
>
>
> Joerg D. wrote:
>> Ok got it thanks. Tried it out. Error is gone. Return value from
>> rebuild_index is false. Is that right?
>>
Jens K. (Guest)
on 2006-04-18 01:02
(Received via mailing list)
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 :-)

Jens


--
webit! Gesellschaft für neue Medien mbH          www.webit.de
Dipl.-Wirtschaftsingenieur Jens Krämer 
removed_email_address@domain.invalid
Schnorrstraße 76                         Tel +49 351 46766  0
D-01069 Dresden                          Fax +49 351 46766 66
Ray B. (Guest)
on 2006-04-23 04:59
Jens K. wrote:

> I could reproduce the error, but I can't explain why it happens ;-)
> 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
This topic is locked and can not be replied to.