addressalign-toparrow-leftarrow-rightbackbellblockcalendarcameraccwcheckchevron-downchevron-leftchevron-rightchevron-small-downchevron-small-leftchevron-small-rightchevron-small-upchevron-upcircle-with-checkcircle-with-crosscircle-with-pluscrossdots-three-verticaleditemptyheartexporteye-with-lineeyefacebookfolderfullheartglobegmailgooglegroupsimageimagesinstagramlinklocation-pinm-swarmSearchmailmessagesminusmoremuplabelShape 3 + Rectangle 1outlookpersonJoin Group on CardStartprice-ribbonImported LayersImported LayersImported Layersshieldstartickettrashtriangle-downtriangle-uptwitteruseryahoo

Re: [ruby-83] Rails Environment Question

From: Micah W.
Sent on: Thursday, October 4, 2012 3:24 PM
I'm with Mike on this, using Chef. I prefer to put my database credentials (and pretty much all other credentials) into an encrypted data bag, then extract them as part of the server bootstrapping.

More here:

My data bags look like so:

  common: {'adapter' : 'mysql2', 'port' : '1234'},
  production: {'host' : '', 'username': 'myuser'},
  staging: {'host' : 'staging', 'username': 'staginguser'}

Chef supports the idea of environments, so if I tell it to bootstrap itself in the staging environment and it will create database.yml with all the staging settings, merged with the common stuff.

For convenience, I also have Chef do a few more things that help with environment segregation:

1) Put the environment in my shell prompt

2) Set the RAILS_ENV environment variable

None of this is particular to Chef, but it's handy to have this in your recipes so any new nodes are automatically booted with this. If you're like me, doing it by hand means that some of the cool bash aliases or helpful prompts are on some machines and not others. With Chef, it's all done immediately and automatically. Very nice.


On Thu, Oct 4, 2012 at 3:09 PM, Kevin <[address removed]> wrote:
And "are" off and running...  (I swear I'm a native English speaker)

On Thu, Oct 4, 2012 at 2:30 PM, Kevin Brown <[address removed]> wrote:

I'm working at a formerly Java and now Java/Erlang(yay!)/Ruby shop w/o hiring any rails folks (I'm a rails 1.0/1.1 guy)...   so our DBAs came along and created new databases in database.yml, set the RAILS_ENV to their new database and our off and running our apps without any config/environment so our apps our running in development mode (fun!)..

So.... I was wondering.

Do folks typically  (#1) create a new environment for each server.  E.g., RAILS_ENV=( atl-production, ny-production), etc and use one big database.yml (potentially) 
or (#2) deploy a rails app running RAILS_ENV=production, and tailor the database.yml production values for each location?

And if the answer is (#2), how can I keep this proliferation of environments DRY?


- kb

Please Note: If you hit "REPLY", your message will be sent to everyone on this mailing list ([address removed])
This message was sent by Kevin ([address removed]) from The Atlanta Ruby Meetup Group.
To learn more about Kevin, visit his/her member profile
Set my mailing list to email me As they are sent | In one daily email | Don't send me mailing list messages

Meetup, PO Box 4668 #37895 New York, New York[masked] | [address removed]

Our Sponsors

  • Mandrill

    Sponsors food, meeting space, and other expenses.

  • Pardot

    Sponsors food, meeting space, and other expenses.

People in this
Meetup are also in:

Sign up

Meetup members, Log in

By clicking "Sign up" or "Sign up using Facebook", you confirm that you accept our Terms of Service & Privacy Policy