B
B
Boober2015-01-20 16:58:04
API
Boober, 2015-01-20 16:58:04

Should you use global variables in Rails?

Hey! I have a Rails application. I also have a list of countries that are taken using the VK API. Storing them in a database is kind of silly. Asking every time is also not cool. So the idea came up to store the list in global variables, executing the request only at the time the server starts.
Can you please tell me the best way to organize such an action?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
A
anyd3v, 2015-01-20
@anyd3v

redis? such techniques do not scale well

V
Viktor Vsk, 2015-01-20
@viktorvsk

https://github.com/huacnlee/rails-settings-cached
Actually, not much different from global variables, but more flexible and looks more logical. Plus, most likely something like this will come in handy anyway.

B
Boris Penkovsky, 2015-01-21
@Able1991

Write a module and store data in it like in a singleton

N
Nikolai Markov, 2015-06-01
@manameiz

It must be stored in the database. Stupid to store in global variables and load at server start

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question