Rodrigo Ruiz
Rodrigo Ruiz

Reputation: 4355

Rails - Active Record or JSON file?

When should I use Active Record's database and when should I use a JSON/YAML/XML (whatever) to store data that won't be changing like list of countries and states or (in my case) spells list.

Something like:

[
    {
        "name": ...
        "require level": ...
        "school": ...
    },
    {
        "name": ...
        "require level": ...
        "school": ...
    }
]

Thank you.

Upvotes: 0

Views: 214

Answers (1)

Ziv Galili
Ziv Galili

Reputation: 1445

For data that won't be changed you should always use YAML/JSON/XML files and not store the information in the database.

Reading data from the db is much slower, so try to avoid it.

In a case that you are not so sure if the data will change or not/you know that the data will change but not often - i would suggest not to use the database as well (thats what i'm doing).

i would recommend to use YAML file, but thats a different topic. you can read about Yaml Vs Json

Upvotes: 1

Related Questions