Forum: Ruby on Rails Library (Ferret) Trampling Namespace

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.
Fraumeni, James (Guest)
on 2006-02-13 19:13
(Received via mailing list)
Greetings. Apologies if I missed something like this in the archives or
internet, but I'm having namespace issues using Ferret with Rails, but
this looks to be an issue with any library and Rails. Specifically, I
have a model class "Weight" in my application and Ferret also has a
class "Weight" in it (Ferret::Search::Weight). My app runs perfectly
fine until it first executes "require 'ferret'". At that point, my
definition of the class "Weight" disappears and I get "uninitialized
constant Weight" errors. I went through my Ferret gem and changed the
Ferret::Search::Weight class to Ferret::Search::FWeight, and all works
	Has anyone else come across an issue of a library trampling namespace?
I have tried putting the indexing code in a number of places within my
app, and "load"ing Ferret rather then "require"ing it, but loading tends
to fail to load Ferret.
	It seems that Rails is taking the application namespace, and applying
it within all of the libraries. I believe this because after changing
Ferret::Search::Weight to Ferret::Search::FWeight, there still is a
Ferret::Search::Weight class, but it matches my model Weight <
ActiveRecord class, and there are Weight  classes that match mine in all
areas of the Ferret library:

	irb> Ferret::Search::FWeight
		=> Ferret::Search::FWeight
	irb> Ferret::Search::Weight
		=> Weight
	irb> Ferret::Search::Weight == Weight
		=> true
	irb> Ferret::Weight == Weight
		=> true
	irb> Ferret::Utils::Weight == Weight
		=> true
	irb> Ferret::Utils::Weight == Ferret::Search::FWeight
		=> false

	Thanks for any insight. I am a Ruby and Rails nuby and am using Win32
(temporarilly), Ruby 1.8.2, Ferret 0.3.2, and Rails 1.0.0.


James Fraumeni
Center for the Evaluation of Value and Risk in Health
Institute for Clinical Research and Health Policy Studies
750 Washington St.
Tufts-New England Medical Center, #063
Boston, MA 02111

Confidentiality Notice
     The information transmitted in this e-mail is intended only for the
person or entity to which it is addressed and may contain confidential
and/or privileged information.  Any review, retransmission,
dissemination or other use of or taking of any action in reliance upon
this information by persons or entities other than the intended
recipient is prohibited.
     If you received this e-mail in error, please contact the sender and
delete the e-mail and any attached material immediately.  Thank you.
This topic is locked and can not be replied to.