How to write to file in Ruby?

ohana picture ohana · May 6, 2010 · Viewed 608.2k times · Source

I need to read the data out of database and then save it in a text file.

How can I do that in Ruby? Is there any file management system in Ruby?

Answer

Todd R picture Todd R · May 6, 2010

Are you looking for the following?

File.open(yourfile, 'w') { |file| file.write("your text") }