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.

Timur Shtatland
  • 12,024
  • 2
  • 30
  • 47
Paul
  • 25,812
  • 38
  • 124
  • 247

3 Answers3

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.

Jakob W
  • 3,347
  • 19
  • 27
  • 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. – Donato Apr 10 '15 at 19:03
9

The public folder is for public content.

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

Vodun
  • 1,377
  • 1
  • 10
  • 12
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
Timur Shtatland
  • 12,024
  • 2
  • 30
  • 47