I have a static string array of Cities, States, Categories, etc that is accessed by my application in various places. Where should I put this? In a yml file someplace or a rb file in the lib directory?
Thanks!
I have a static string array of Cities, States, Categories, etc that is accessed by my application in various places. Where should I put this? In a yml file someplace or a rb file in the lib directory?
Thanks!
See this so question
Basically, put constants in /config/initializers
in a .rb
file.
So this is not really constant data since "once a couple of months" the info will change. In that case you should put the info in the database and cache it. The caching will prevent round trips to the database and you can expire the cache when you need to update the info.
I advise you to put this in config/locales/*.yml
files. It's good because you can specify different city names for different languages. See internationalization guide for more information.