Rails - where to put data files?
Asked Answered
A

3

15

I wonder where to put data files (for example XML) to be loaded internally by Rails? Is there some standard location? Now I hold the file in "public" folder.

Airfoil answered 27/3, 2012 at 11:50 Comment(0)
E
13

I think that depends on which kind of data you have in your files. If the files are supposed to be loaded at startup, perhaps the config folder would be good. If they are needed for some backend processing, lib could be the place. Or just create a data folder.

There's a table at the end of section 3.2 here with the default folders and their intended purpose.

Elemi answered 27/3, 2012 at 11:59 Comment(1)
I'm thinking lib will be better than data folder, because most likely the custom files will be manipulated with rake tasks, which itself is in lib.Earthman
R
9

The public folder is for public content.

You can create a folder "data" at the root of your app without any problem.

Recall answered 27/3, 2012 at 11:55 Comment(0)
G
0

Copying the answer from Hyrme from this thread: Where to store static data for Rails app? : rails

You have multiple choices depending on what the data is used for. Keep it under

  • db/data
  • or create a new folder called data/ under the project
  • or if this is configuration information keep it under config/data
Grane answered 6/10, 2021 at 15:6 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.