Forum: Ruby on Rails creating xml files on the hard disk

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
70dc5b6a5bf97779ee34d2865539f50b?d=identicon&s=25 Luma (Guest)
on 2007-03-28 01:43
(Received via mailing list)
I've written a rxml template. What must I write in my rails-controller
to get xml files out of this - not displayed on the screen, but just
saved on the hard disk? And where do I have to store the rxml file?
8310c5a7c769345114597bcdef111488?d=identicon&s=25 Ben Munat (Guest)
on 2007-03-28 06:16
(Received via mailing list)
Well, if you already have a controller and the rxml template, then all
you need do to get the xml written to the file system is to turn on page
caching for that action. Check out the docs:

http://api.rubyonrails.org/classes/ActionControlle...

There's also good coverage of caching in the agile rails book. Plus
google will probably give you a lot of help too.

b
1444deb5f2241b9e1c7cd226a6a1f6c4?d=identicon&s=25 Sébastien Boisvert (sebhtml) (Guest)
on 2007-03-28 19:33
(Received via mailing list)
Hi,

On Mar 27, 7:42 pm, "Luma" <herbert....@t-online.de> wrote:
> I've written a rxml template. What must I write in my rails-controller
> to get xml files out of this - not displayed on the screen, but just
> saved on the hard disk? And where do I have to store the rxml file?

Actually, you could be doing it without using caching.......


class LaboratoryNotebookController < ApplicationController

  def index
    render :action => 'index.rxml'

    fp = File.open RAILS_ROOT+"/myfile.xml", 'w+'
    fp.write @response.body
    fp.close
  end

end


remember that XHTML is actually XML too, therefore, the rxml extension
or the rhtml extension is not really important.....
70dc5b6a5bf97779ee34d2865539f50b?d=identicon&s=25 Luma (Guest)
on 2007-03-28 19:53
(Received via mailing list)
This is a good idea. Now I tried to simulate a post request for the
action "create_xml" like this:

xhr :post, :create_xml, :order => @order


But rails doesn't know the "xhr". Do I need to include
"ActionController::TestProcess", and what is the syntax?

undefined method `xhr' for #<BestellContrController:0x4660374>
RAILS_ROOT: ./script/../config/..

Application Trace | Framework Trace | Full Trace
#{RAILS_ROOT}/app/controllers/bestell_contr_controller.rb:19:in
`save_order'


Thanks for help.
70dc5b6a5bf97779ee34d2865539f50b?d=identicon&s=25 Luma (Guest)
on 2007-03-28 22:23
(Received via mailing list)
It works. Thanks to both of you!
This topic is locked and can not be replied to.