<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><div>You need to eval the production file with the current context, like so:</div><div><br></div><div> config = configuration # Need local config variable</div><div> eval(IO.read(path), binding, path)</div><div><br></div></div><div>Alex</div><div><br><blockquote type="cite"><div>----------------------------------------------------------------------<br><br>Message: 1<br>Date: Mon, 12 Apr 2010 17:07:44 +0100<br>From: Tim Cowlishaw <<a href="mailto:tim@timcowlishaw.co.uk">tim@timcowlishaw.co.uk</a>><br>To: LRUG LRUG <<a href="mailto:chat@lrug.org">chat@lrug.org</a>><br>Subject: [LRUG] requiring one rails environment from another<br>Message-ID: <<a href="mailto:2097FF98-1CDD-46A9-847E-DA9060CDBBED@timcowlishaw.co.uk">2097FF98-1CDD-46A9-847E-DA9060CDBBED@timcowlishaw.co.uk</a>><br>Content-Type: text/plain; charset=us-ascii<br><br>Hey there chaps,<br><br>I'm in the middle of setting up a CI server for our office and have run into what seems like a slight gotcha.<br><br>Basically, i need to set up a seperate rails environment called something like "CI", so that the CI server can have its own mysql credentials, rather than requiring all users to user the same. So, i set this up in database.yml, and create a ci.rb file in config/environments that contains only a "require File.dirname(__FILE__)+ '/test.rb'" to load in the regular test environment. However, as the code in the required file isn't evaled in the same context as where the 'require' happens - it fails with "undefined local variable or method `config' for main:Object" on the line "config.cache_classes = true", the first line in the required 'test.rb'.<br><br>Clearly I'm going about this the wrong way - has anyone else any bright ideas about allowing two distinct environments to share configuration, without resorting to putting it all in environment.rb?<br><br>Cheers,<br><br>Tim<br><font class="Apple-style-span" color="#000000"><font class="Apple-style-span" color="#144FAE"><br></font></font></div></blockquote></div></body></html>