Opening file content into a textarea



Can somebody help me on how to open a file and show it on a text area,
and be able to edit it and save it again.



in ruby there is the class File:

to get the contents of your file try something like:
my_file =, ‘r’)
@my_file_content =

now you can show your content inside the text area (you should know
how to build a simple form for it).

after editing it, back in your controller write the updated contents
to the file:
updated_content = params[:whatever]
my_file =, ‘w’)


Many thanks MaD, I’ll try it out.