Ask A Question

Notifications

You’re not receiving notifications from this thread.

Environment Variables | GoRails

Chris Oliver asked in General
borealsummit borealsummit

Very clear about how the export command and subsequently the .bash_profile file work. We're currently taking advantage of this strategy by telling Puppet to deploy our keys into our servers and setting them in ENV variables instead of having them in our repos. Thanks.

Reply

So awesome. It's great to see this kind of foundational content before delving into Rails. And it's nice to see the mentions of zsh, rbenv, irb, vim, etc so that those of us who are new to things can pick up on some bonus material outside of the main env topic.

Reply
Bruno Batista Bruno Batista

Nice. Thanks!

Reply

Thank goodness, finally a video that explains this perfectly. Love it. Really like the part where you took time to explain how the environment variable will be "temporary", "semi temporary", and then "permanent" because .bash_profile is loaded when the terminal runs. It was also good to see the larger picture that this is very useful to store API keys locally

Reply

That was a really helpful guide, thanks for posting it. Keep up the good work!

Reply
Nikola Novakovic Nikola Novakovic

A really really nice explanation of env vars. I did not find more simpler and more clearer explanation to the thing that always sorta bugged me since it had too much "magic" in it.
Thanks a ton Chris.

Reply

.bash_profile vs. .bashrc, and why MacOS X Terminal.app is an exception, for the possibly confused: http://www.joshstaiger.org/...

Reply

Nice! I used this to create shortcuts for myself. For example, I can type 'dev' into my terminal, and it changes directory to my Development folder.

Reply

I have a question regarding ENV variables.

Suppose I have just a single Rails appon my Development environment. Then in this case I could use ENV vars to save my db credentials, so I could do something like this on my bashrc file:

export DB_USERNAME="my-username"
export DB_PASSWORD="my-password"
export DATABASE="railsapp_development"

This seems pretty straight forward but what there are more than one project on the development environment? I guess the username and password are same, but the database name changes on each project because projects don't usually share the same database, right?

How to use a different database name for each project in this case then?

Reply

Check out https://github.com/rbenv/rb...

This lets you write a .rbenv-vars file in your rails app directory and set environment variables separately outside of your Rails app.

I'm using this for the new Rails hosting service I'm working on and it works wonderfully for separating environment variables out for each app.

Reply
Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 87,563+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.