I am using Ruby on Rails and have a form that gets information from user input. I then want to take the user input and write it to a text file on the server side. I hope to save the file in somewhere such as /public/UserInput.txt.
Is there a way to use Ruby on Rails to do this? Or do I need a different language to do this such as PHP? In either case can anyone give me an example of how this is to be done?
Thanks in advance.
Update The code I am trying that is not giving me a text file is:
after_save :create_file
def create_file
parameter_file = File.new('C:\\parameter_file.txt', "w")
parameter_file.puts(:parameter)
end
open, or, more simplyFile.write, so the file is automatically closed? Failing to close the file handle will consume all available file handles on your machine eventually and crash your code.