Saving to_xml to a file

Ok, one more question…

I can dump the database to xml by doing User.to_xml

I’m wondering if I can save it to a .xml file. I’m having trouble
finding documentation on this.

Thanks!!

Can you even save files using Rails? I haven’t found a way to do it
yet… Thanks

Sam Purtill wrote:

Can you even save files using Rails? I haven’t found a way to do it
yet… Thanks

You do anything in Rails the same way you’d do it with Ruby itself. In
Rails, you probably have protected directories - you’ll need to
unprotect the directories first so you can save files there.

Look up File.open.
http://uic.rsu.ru/doc/programming/ruby/ProgrammingRuby/html/tut_io.html

You can practice in script/console to get your syntax right.

        - dan


Dan K. mailto:[email protected]
http://www.dankohn.com/ tel:+1-415-233-1000