Where to store XML files in Rails - ruby-on-rails

I am writing a Ruby on Rails site which loads some data from an "local" XML file which I have. Where is a logical place in the rails directory structure to store this file?

Main question here is for what reason you have that XML files: configuration info or data storage. If first - then best place will be congif folder, otherwise - anywhere you like except public folder, you could even create xml folder inside app one.

Related

Default value in core data

I have core data file generated by my app. This file contains a data. But I don't want this file generate in every user device. I want put this file in app and every user uses this file. How can I do this?
I have find answer here:
https://gist.github.com/xavierchia/ef43abb270003ae63e5bbb7eb5404645
I need just copy my SQL files to project and copy them in app directory.

Where is the swagger json schema located?

The help for swashbuckle mentions that the ui for Swagger is driven by the generated json schema.
Where is this json file located?
I cannot find it in the folder for my asp.net project
When I actually run the application and navigate to http://localhost:51659/swagger/v1/swagger.json
then I see the json
Where is it on disk? Or is it only in memory?
There is no file generated, it is only on memory.
You might want to read a bit the code:
https://github.com/domaindrivendev/Swashbuckle/blob/master/Swashbuckle.Core/Swagger/SwaggerGenerator.cs
If you need a file you could create an IDocumentFilter to generate one. I have an example here generating a Yaml file:
https://github.com/heldersepu/Swagger-Net-Test/blob/master/Swagger_Test/App_Start/SwaggerConfig.cs#L378

How to retrieve a FileBlob from 'ActionDispatch::Http::UploadedFile' instance?

I have used 'remotipart' gem to upload files asynchronously to server side. The instance passed to the server side is of 'UploadedFile' .
The Rails API mentions all the methods( like read(), open() ) and attributes for the class, however I am not sure how to retrieve the File and store it on the database?
Googling took me to no tutorials using this class.
This is rarely documented because most people use gems to handle file uploads.
Let's say your object is called file. You could determine the path using this:
file.tempfile.to_path.to_s
You should move the file because it's stored in /tmp and might be deleted by the system. You can use FileUtils.mv method for this. Then you can add the new path of the file to the database.

plist in Index.html using phonegap

Can I read a plist file in my index.HTML? Actually I want to add multiple links with which application will interact, and I want those links to be in a plist. Is there any way to retrieve them in HTML file?
please help
thanks
Well, if the file is in the www folder, you could parse it using an XML parser, or even a specialty plist parser such as this: https://github.com/pugetive/plist_parser
If you are looking to have the file outside the www folder you might also need to use PhoneGap's File API to get the contents of the file.

How to read list of files from a folder an export into database in Grails

I have lots of files of same type like .xml in a folder. How can I select this folder from interface and iterate over each file and send this to appropriate tables of database.
Thanks
Sonu
Do you always put the files in the same directory? For example, if you generate these files in some other system, then just want the data imported into your application you could:
Create a job that runs every X minutes
It iterates over each file in the directory and parses the XML, creating and saving the objects to the database
Shifts or deletes the files when it has processed them
Jobs are a Grails concept/plugin: http://www.grails.org/Job+Scheduling+(Quartz)
Processing XML is easy in Groovy - you have many options, depends on your specific scenario - http://groovy.codehaus.org/Processing+XML
Processing files is also trivial - http://groovy.codehaus.org/groovy-jdk/java/io/File.html#eachFile(groovy.lang.Closure)
This is a high level overview. Hope it helps.

Resources