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

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?


search' /Users/aravet/Desktop/Locomotive/Bundles/RubyonRails-1.0-Min.locobundle/Contents/Resources/unix/lib/ruby/site_ruby/1.8/ferret/index/index.rb:622:indo_search’
search_each' /Users/aravet/Desktop/Locomotive/Bundles/RubyonRails-1.0-Min.locobundle/Contents/Resources/unix/lib/ruby/1.8/monitor.rb:229:insynchronize’
search_each' #{RAILS_ROOT}/app/models/result.rb:27:insearch_index’
#{RAILS_ROOT}/app/models/result.rb:15:in count' #{RAILS_ROOT}/app/controllers/search_controller.rb:31:inget_results’

Any idea

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.


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
http://ferret.davebalmain.com 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 http://www.ruby-forum.com. 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 P.

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).


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. :smiley: Expect the next couple of versions of ferret to
be even less stable.


I posted a resolution to the “undefined method `weight’” error message
on the rails website:



This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs