I have a txt file stored in file system. I want to read the content of that file in single go and assign it to a varialble. whichever function i try i get this error
Error: undefined method 'root' for #
How can i do this?
You can read a file in Ruby using the File.read
function:
s = File.read 'your_file_name.txt'
Now, the variable s
will have the file's content.