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.
Rails - where to put data files?
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.
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
The public folder is for public content.
You can create a folder "data" at the root of your app without any problem.
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
© 2022 - 2024 — McMap. All rights reserved.