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.
34791e1d8c4def65f9b93294638a7e04?d=identicon&s=25 Joerg Diekmann (joergd)
on 2006-04-13 17: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
B39d86f427c04b5df1e8ceca920bd14d?d=identicon&s=25 Kasper Weibel (weibel)
on 2006-04-13 18: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 Diekmann 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'
34791e1d8c4def65f9b93294638a7e04?d=identicon&s=25 Joerg Diekmann (joergd)
on 2006-04-13 20: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 Weibel 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 Diekmann 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'
C9dd93aa135988cabf9183d3210665ca?d=identicon&s=25 Jens Kraemer (Guest)
on 2006-04-17 17: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 Diekmann 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
> Ferret-talk@rubyforge.org
> http://rubyforge.org/mailman/listinfo/ferret-talk

--
webit! Gesellschaft für neue Medien mbH          www.webit.de
Dipl.-Wirtschaftsingenieur Jens Krämer       kraemer@webit.de
Schnorrstraße 76                         Tel +49 351 46766  0
D-01069 Dresden                          Fax +49 351 46766 66
34791e1d8c4def65f9b93294638a7e04?d=identicon&s=25 Joerg Diekmann (joergd)
on 2006-04-17 18: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 Kraemer 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.
B39d86f427c04b5df1e8ceca920bd14d?d=identicon&s=25 Kasper Weibel (weibel)
on 2006-04-17 18:39
That's an old location. Try here instead (or use SVN)
http://projects.jkraemer.net/acts_as_ferret/browse...


Joerg Diekmann 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 Kraemer 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.
34791e1d8c4def65f9b93294638a7e04?d=identicon&s=25 Joerg Diekmann (joergd)
on 2006-04-17 18:57
Ok got it thanks. Tried it out. Error is gone. Return value from
rebuild_index is false. Is that right?

Kasper Weibel wrote:
> That's an old location. Try here instead (or use SVN)
> 
http://projects.jkraemer.net/acts_as_ferret/browse...
>
>
B39d86f427c04b5df1e8ceca920bd14d?d=identicon&s=25 Kasper Weibel (weibel)
on 2006-04-17 19:08
According to the API false is the correct value
http://ferret.davebalmain.com/api/classes/Ferret/I...


Joerg Diekmann wrote:
> Ok got it thanks. Tried it out. Error is gone. Return value from
> rebuild_index is false. Is that right?
>
34791e1d8c4def65f9b93294638a7e04?d=identicon&s=25 Joerg Diekmann (joergd)
on 2006-04-17 19:51
K great. Well - I tested it by doing searches, and my content was
correctly indexed.

Thanks a lot for your help!

Joerg

Kasper Weibel wrote:
> According to the API false is the correct value
> http://ferret.davebalmain.com/api/classes/Ferret/I...
>
>
> Joerg Diekmann wrote:
>> Ok got it thanks. Tried it out. Error is gone. Return value from
>> rebuild_index is false. Is that right?
>>
C9dd93aa135988cabf9183d3210665ca?d=identicon&s=25 Jens Kraemer (Guest)
on 2006-04-17 23:02
(Received via mailing list)
On Mon, Apr 17, 2006 at 07:51:07PM +0200, Joerg Diekmann 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       kraemer@webit.de
Schnorrstraße 76                         Tel +49 351 46766  0
D-01069 Dresden                          Fax +49 351 46766 66
39cbcb6fffcf5b6320e35bc2529b02bb?d=identicon&s=25 Ray Baxter (Guest)
on 2006-04-23 02:59
Jens Kraemer 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.