Setting up environment variables for RoR app?

rails

#1

I am new on C9 and RoR, and following some Stack Overflow advice, have created my MailChimp and Sendgrid information (email, username and password) in the .profile file on C9 (for environment variables).

After saving this file, I opened up another terminal window to test, and entered echo “SENDGRID_USERNAME” to see if it would return my information, but it did not, only returning SENDGRID_USERNAME (without quotes).

FYI, I am creating all my information entirely on C9, and have not uploaded any local files up to C9. Am I entering my information in the right place with the .profile file? Or should I save it somewhere else?

Thank you in advance.


#2

What you are doing is simple, by writing echo "something in quotes", you are instructing bash to echo what ever is in the quotes, treating it as a string and not executing anything in it. If you want to get an environment variable, just use echo $SENDGRID_USERNAME, where $ denotes a variable.