Search code examples
ruby-on-railsenvironment-variablescloud9-ide

Environment variabels unaccessible from rails


I am building a rails application where I have some initial configuration files that use environment variables, and I'm using the cloud9 ide. I am setting the environment variables using export, yet when the server is running rails tells me the parameter whose value is supposed to be one of the environment variables is missing, and when I used the debugger, ENV["VAR_NAME"] returns nothing. Any ideas why? When I run echo $VAR_NAME in bash, it returns the correct value.

EDIT: When I run console --sandbox, the environment variables are also available. Only in the controller are they not available.


Solution

  • I fixed this by adding export VAR_NAME=var_value in .bashrc.