Welcome Guest | Login

Using rails to create a text file

Hi,

I would like to have rails create a text file for me.  I've searched Google but have come up empty handed.  I used to do this in ASP all the time, so I'm sure it's easy in Rails, I just can't find the code anywhere.

Does any one know how to do this?

Thanks,

Bry

2007-03-06 07:41 AM

Check out my comic sketches
Yeah -

f = File.new("testfile", "r")

check out the File class:  

http://www.rubycentral.com/ref/ref_c_file.html

That's an old reference for 1.8.4 I think (or maybe back at 1.6, I'm not sure) - but I think most of the methods will be the same.  

Cheers,

~William

2007-03-06 10:10 AM

  f = File.new("/home/comicsk/gallery_site/public/javascripts/galleries/test.js", "wb")
  f.write("some stuff in the file")
  f.close

This code runs fine, and I get no errors, however no file is written to the server (that I can find).

Any ideas?

Bry

2007-03-06 11:28 AM

Check out my comic sketches

Hello Guest! In order to post you must be an active client with us, please log in or sign up today!