In the controller my Rails project, I would like to create a new file /public/my_files/welcome.txt with content
Welcome to my website!
(The folder my_files does not exist yet.)
How can I do that?
(Edit: I know that to make a static page, I don’t need to do it via a controller. I’m actually making a dynamic page, but I’m just simplifying the example.)
This is the simplest way you can create a file. Ruby will automatically create the file if not present. Let me know if this fits within your requirment.