Reputation: 5283
In the Rails controller, I'd like to write create a new file at public/my_file.txt
and write the string This file is my_file.txt
into the file. How can I do that?
Upvotes: 3
Views: 768
Reputation: 621
File.open([full path to your file], 'w') { |file| file.write("your text") }
More info via ruby's file class
Upvotes: 4