[Backgroundrb-devel] Using mapped database connections

Geoff Garside ruby at geoffgarside.co.uk
Mon Apr 23 06:01:09 EDT 2007


This morning I switched over my backgroundrb server from development  
mode to production mode. After that all I was getting was errors when  
attempting to connect to the backgroundrb server. I checked the  
backgroundrb_server.log file and noticed the following exception

	20070423-10:30:00 (29673) development database is not configured -  
(ActiveRecord::AdapterNotSpecified)

In my database.yml file I have the production database setup as

	production:
	  development

to map the production database back to the development one.  
Unfortunately BackgrounDRb::Worker::RailsBase doesn't know how to  
handle these types of database references. I also had a quick play  
with loading up irb and then requiring the config/boot.rb and config/ 
environment.rb files. Once I had done this I could access all my  
Rails models as I would expect.

So I was wondering why the RailsBase class tries to do more than just

	require BACKGROUNDRB_ROOT + '/config/boot.rb'
	require BACKGROUNDRB_ROOT + '/config/environment.rb'

if BackgrounDRb needs to set its own rails_env so that it can use a  
different database or something like that then ENV['RAILS_ENV'] would  
need to be set before requiring config/boot.rb but that still  
wouldn't require loading the database config manually.

Alternatively, if it has to be done the way it is then the following  
code could be used

	if db_config[rails_environment].kind_of?(String)
		db_config[rails_environment] = db_config[db_config[rails_environment]]
	end

backgrounDRb would then be able to handle instances when one rails  
environments database is mapped to that of another.

Is this right or have I missed something somewhere?

- Geoff


More information about the Backgroundrb-devel mailing list