Timeline for How to write to file in Ruby?
Current License: CC BY-SA 4.0
11 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Apr 21, 2024 at 10:07 | comment | added | user2617804 | The guy like me is probably hundreds of lines text to a file- these answer doesn't address it well. Lots of ruby help don't address it well. | |
| Dec 8, 2018 at 15:00 | comment | added | Joshua Pinter | To add to my own comment 3 years later, you can pass mode: 'a' as the third param and it will append to the file, if it exists. I updated the Answer with that example. | |
| Dec 8, 2018 at 14:58 | history | edited | Joshua Pinter | CC BY-SA 4.0 | Add append example. |
| May 25, 2016 at 3:00 | comment | added | Dishcandanty | I think this is the best answer as well | |
| Sep 14, 2015 at 22:00 | comment | added | B Seven | This seems like the best answer ATM. | |
| May 11, 2015 at 3:43 | comment | added | mklement0 | @JoshPinter: it overwrites. | |
| Mar 10, 2015 at 16:24 | comment | added | Joshua Pinter | Will this append to a file or just overwrite it? | |
| Jan 2, 2015 at 1:32 | comment | added | nruth | IO class docs say it does close the file | |
| Sep 17, 2014 at 19:20 | comment | added | Freedom_Ben | FYI this does properly close the file when finished. | |
| Apr 17, 2014 at 15:43 | comment | added | Andrew Burns | FYI this shorthand method only works beginning with Ruby 1.9.3. There is, no such method in any earlier versions of 1.9 or 1.8. In that case you must use the longer block method posted by @mvndaai | |
| Oct 12, 2013 at 17:56 | history | answered | Sébastien Le Callonnec | CC BY-SA 3.0 |