I've been writing Rails apps for so long that I'm suddenly stuck with something you get for free with Rails: environments.

That is to say, you can run the Rails app locally and by default, RAILS\_ENV (or Rails.env) is "development". And if you are running your specs/tests, it's "test" and when you deploy to your production server, you set it up to run as "production".

This is particularly useful when you have config files. Also useful for the Gemfile to differentiate gems for certain environments.

So now to my question: I'm writing a pure Ruby app and I don't know the best way to set it up so that I can still have the multiple environments? I want to set up config files for 3rd-party services (like MongoLab/Iron.IO/etc.) but I want them set up with "development", "test", "production", etc. And then I want to be able to run the app from various environments.

I know I could just manually handle it via command-line environment variables, but I'm wondering if there are best (better?) practices for this? Any gems that help with this? Or any recommendations for how to structure environment handling for a pure Ruby app?

Thanks,