You are here: Forums Ask a Rails expert Create an XML "file" in memory...
Posted in Forums : Ask a Rails expert
Authority 12
Posting Rating 100
Sign in to rate this post
|
I have a Flash gallery object that takes an xml file as a parameter to load the images. Creating the xml file is not a problem, I already handled that. My problem is that I have a bunch of these galleries all over my site and the XML is created dynamically from my database and I don’t want to have to worry about reading/writing/updating a bunch of xml files for this purpose. First, I think it will unnecessarily slow. Second, I have to worry about deleting and recreating the xml files to keep them up to date, different file names for everything, etc., etc. Can I create a file named “gallery.xml” in memory and pass it into my partial’s javascript to fill in the param? An xml string doesn’t work. Already tried it. I also tried using send_data like this: send_data stream, :filename => 'gallery.xml', :type => 'text/xml', :disposition => 'inline
but that just returns the (properly formatted) xml back to the browser. |
Authority 62
Posting Rating 86
Sign in to rate this post
|
It depends on what your partial is doing. If your partial expects a params like hash, you could use Hash.from_xml to parse the XML and turn it into a Hash. Otherwise, please post the details of the partial. |
Authority 12
Posting Rating 100
Sign in to rate this post
|
Thanks for the reply. I figured it out. But here’s my code and solution.
In the javascript, the parameter called ‘xml:’ is where you specify the path to the xml file spelling out the image paths you want to show. Previously I was using send_data to stream a file straight to that parameter but it was just rendering in the browser. But it expects a path to a file. So I created a controller action that triggers the xml send_data method and using url_for, all is well. I hope this was clear enough to help someone else. |
Authority 12
Posting Rating 74
Sign in to rate this post
|
hi i want to pass a list of playlist in my video so i have used xml for this but it did not reflect any thing on that so how i can do that Thanks Amit Agarwal |
Authority 12
Posting Rating 100
Sign in to rate this post
|
Please provide some more info about how you are using the xml. Is there a flash object looking for a file somewhere or is there some other situation going on here? |
Authority 12
Posting Rating 74
Sign in to rate this post
|
Hi
i create the xml file in my public folder and i want to pass some value from my database so i will do this.
Thanks |
Authority 12
Posting Rating 74
Sign in to rate this post
|
Hi ######################
|
Ask a Rails expert : how to execute the url from my controller
Ask a Rails expert : conditional action caching multiple mongrel clusters
Ask a Rails expert : Using like command in RoR
Ask a Rails expert : Apache ActionController:RoutingError
Ask a Rails expert : Multiple csv file upload based on data in a form
Ask a Rails expert : Exception error code
Ask a Rails expert : Tracking down an issue
Ask a Rails expert : Thread Vs Transaction
Ask a Rails expert : implementing whitelist plugin
Ask a Rails expert : Validation helper