Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Keeping a set of environment variables in rails and javascript

essentially, we want to keep a set of constants to be used across the rails app and javascript code. For example:

{A:3
B:4
C:5}

We try not to embed rails code in javascript, and we do not want 2 copies of constants.

Thanks!

like image 443
meow Avatar asked Mar 24 '10 22:03

meow


People also ask

Where are Rails environment variables stored?

Keeping Environment Variables PrivateRemote git repositories such as GitHub are a place to store and share code. If your project is open source, any developer will have access to your code. You don't want to share email account credentials or private API keys with the public.

Where should I store environment variables?

The Global environment variables of your system are stored in /etc/environment . Any changes here will get reflected throughout the system and will affect all users of the system. Also, you need a Reboot, for any changes made here to take effect.

Where are Ruby environment variables stored?

You store separate environment variables in config/development. rb , config/testing. rb and config/production. rb respectively.


1 Answers

put it in JSON file and parse it in your ruby file and same in your javascript file.

like image 197
shingara Avatar answered Sep 21 '22 10:09

shingara