[Backgroundrb-devel] Unable to load Models which reference plugins?

James Howison james at howison.name
Tue Jan 22 20:21:15 EST 2008


On Jan 22, 2008, at 6:51 PM, Yves-Eric Martin wrote:

> hemant wrote:
>> Looks like you are having a model called event and backgroundrb has a
>> class called Event and hence when bdrb is trying to load event class
>> of its own, its loading your model and its failing.
>>
>> Sadly to overcome this, you will have to perhaps rename your model

I'm certainly able to change my Model names, since it's early in the  
game for this application, but seems that there is a more general  
issue with namespaces here.  Presumably the same thing would happen if  
I had a file matching any of the requires in packet.rb (including  
pimp ;)

> Could changing "Event" to "Packet::Event" help bdrb load the correct  
> class?

Seems that the issue comes from the "require 'event'" line at bdrb's  
packet.rb:10 file.  That line is picking up my RAILS_ROOT/app/model/ 
event.rb file.

Changing that line to:

require './vendor/plugins/backgroundrb/framework/event.rb'

seems to work, at least bdrb is able to start.

I'm very far from really understanding Ruby's namespaces, but the call  
to dbrb's Event.new on core.rb:215 is inside a Packet module ...  
perhaps that will protect it. Perhaps better, though, if bdrb could be  
very pedantic about the namespacing it uses (either includes or full  
Package names for it's internal classes, as suggested above).  Maybe  
even a top level BDRB package for everything?

Thx,
James

ps. Is there any smart automated way to change a Rails Model's name,  
it is scattered all over the place, in files and filenames, not to  
mention the database?


More information about the Backgroundrb-devel mailing list