[Backgroundrb-devel] Rails after_initialize block doesn't seem to be run in the backgroundrb context

Nicholas Thomas nick at bytemark.co.uk
Tue Jan 12 08:48:13 EST 2010

Hi all,

Just had an interesting production failure while updating my Rails
application - a bunch of code previously in config/environment.rb was
put into config/initializers. That resulted in me having to wrap some
code in config/environments/production.rb into an after_initialize
do ... end block

When backgroundrb was run against that code, the setup done in that
after_initialize block wasn't run, leading to a failure in several
background jobs that required it.

Two purposes for the email - firstly, a heads-up that this is a problem,
in case anyone else ends up bashing their heads against it. Secondly,
anyone know how to /fix/ this? I've worked around it for now by moving
the wrapped code into config/environment.rb, after Rails::Initializer
do... end, wrapped in an if RAILS_ENV=production do ... end block -
which is hardly ideal, although it has the advantage of working for
now... ;)


More information about the Backgroundrb-devel mailing list