[LRUG] requiring one rails environment from another
Kenneth Lee
kenfodder at gmail.com
Tue Apr 13 09:41:40 PDT 2010
That's also a good pattern for deployment scripts e.g. using capistrano
to copy database.production|staging|alpha.yml -> database.yml
I avoid having a database.yml that has dev/test/other envs mixed with
production. Has saved me many times when forgetting to specify an
environment. YMMV.
Ken
Matthew Rudy Jacobs wrote:
> I always do this
>
> * keep my standard database.yml as a database.example.yml
> * keep database.yml out of version control
> * for a dev setup copy database.example.yml -> database.yml
>
> can't remember where I picked this up from
> but it seems to work.
>
> On 14 April 2010 00:28, Tim Cowlishaw <tim at timcowlishaw.co.uk
> <mailto:tim at timcowlishaw.co.uk>> wrote:
>
> aah, that's useful, thanks! Have decided to go with an
> unchecked-in database.yml but will take note.
>
> On 13 Apr 2010, at 00:47, Alex MacCaw wrote:
>
> > You need to eval the production file with the current context,
> like so:
> >
> > config = configuration # Need local config variable
> > eval(IO.read(path), binding, path)
> >
> > Alex
> >
> >>
> ----------------------------------------------------------------------
> >>
> >> Message: 1
> >> Date: Mon, 12 Apr 2010 17:07:44 +0100
> >> From: Tim Cowlishaw <tim at timcowlishaw.co.uk
> <mailto:tim at timcowlishaw.co.uk>>
> >> To: LRUG LRUG <chat at lrug.org <mailto:chat at lrug.org>>
> >> Subject: [LRUG] requiring one rails environment from another
> >> Message-ID:
> <2097FF98-1CDD-46A9-847E-DA9060CDBBED at timcowlishaw.co.uk
> <mailto:2097FF98-1CDD-46A9-847E-DA9060CDBBED at timcowlishaw.co.uk>>
> >> Content-Type: text/plain; charset=us-ascii
> >>
> >> Hey there chaps,
> >>
> >> I'm in the middle of setting up a CI server for our office and
> have run into what seems like a slight gotcha.
> >>
> >> 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'.
> >>
> >> 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?
> >>
> >> Cheers,
> >>
> >> Tim
> >>
> > _______________________________________________
> > Chat mailing list
> > Chat at lists.lrug.org <mailto:Chat at lists.lrug.org>
> > http://lists.lrug.org/listinfo.cgi/chat-lrug.org
>
> _______________________________________________
> Chat mailing list
> Chat at lists.lrug.org <mailto:Chat at lists.lrug.org>
> http://lists.lrug.org/listinfo.cgi/chat-lrug.org
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Chat mailing list
> Chat at lists.lrug.org
> http://lists.lrug.org/listinfo.cgi/chat-lrug.org
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lrug.org/pipermail/chat-lrug.org/attachments/20100413/b656041f/attachment-0003.html>
More information about the Chat
mailing list