Forum: Ferret EdgeRails: "undefined method `weight' for #<Hash:

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
B45eab4f18aa1bb2a44d6e657531a642?d=identicon&s=25 Alain Ravet (aravet)
on 2006-03-29 15:23
Hi all,

I was playing with the sample project found on the Wiki at
, and everything was working fine, ... till I moved to EdgeRails :
    undefined method `weight' for #<Hash:0x22c7150>

(full error thread below)

Any idea?


#{RAILS_ROOT}/app/models/result.rb:27:in `search_index'
#{RAILS_ROOT}/app/models/result.rb:15:in `count'
#{RAILS_ROOT}/app/controllers/search_controller.rb:31:in `get_results'

Any idea
B45eab4f18aa1bb2a44d6e657531a642?d=identicon&s=25 Alain Ravet (aravet)
on 2006-03-29 16:06
additional info: I also tried without the c extension, without success.

For the 1st unsuccessful attemp, I just installed the gem

   $  gem install ferret.

For the 2nd attempt,
I uninstalled the gem
     $  gem uninstall ferret.
and installed from the zip file, AND skipped the c extension
compilation, as indicated on Trac
    $ ruby setup.rb config
    $ ruby setup.rb  install

I've looked in the ferret code and noticed that a weight method can be
found in the Query class, that doesn't extend Hash. I'm puzzled by the
error message and more than annoyed, as my project runs on EdgeRails.

E48d29dc8fedb2878fa518d41cc63d88?d=identicon&s=25 Jan Prill (Guest)
on 2006-03-29 16:26
(Received via mailing list)
Hi, Alain,

since I've originally posted this HowTo to the RoR-wiki but haven't got
time right now even for the small contribution of helping to keep this
up to date I'm not quite sure if it is about time to delete the sample
project. There has been happened so much in ferret as well as on rails
it's no wonder that something isn't working any longer. My advice right
is: Don't be disappointed or annoyed but have a look at the ferret wiki and look at the integration efforts under
acts_as_ferret. There even is a svn-tree for integrating  ferret with
You should find the location of this as well on the ferret wiki and in
archives of ferret-talk on And maybe as you
going on you'll have the time to update the rails wiki as well. Sorry
the unconvenience, but I've got exams in a few month and am learning all
time. All things IT aren't really happening for me right now...

Best Regards
Jan Prill
B45eab4f18aa1bb2a44d6e657531a642?d=identicon&s=25 Alain Ravet (aravet)
on 2006-03-30 09:16
I started from scratch on EdgeRails, and it worked.
It's strange though, that changing the Rails version has an impact on
Ferret (that doesn't require Rails).

B5e329ffa0cc78efbfc7ae2d084c149f?d=identicon&s=25 David Balmain (Guest)
on 2006-03-30 19:32
(Received via mailing list)
Hi Alain,

I'm glad the problem seems to have fixed itself. Basically what must
have been happening was that a Hash was being passed to the
search_each method instead of a String. The search_each method knows
how to convert a String to a Query but a Hash will cause the error you
saw. I don't know exactly why changing the Rails version would do
something like that but I've had a similar problem in the past. That's
why it's EdgeRails. :D Expect the next couple of versions of ferret to
be even less stable.

0cb06aca87d1e400c559c0cc5422cc68?d=identicon&s=25 Mr (Guest)
on 2006-04-02 08:55
(Received via mailing list)
I posted a resolution to the "undefined method `weight'" error message
on the rails website:

This topic is locked and can not be replied to.