How to read & render a text file?

Hello Everyone.

There is a method withing controller which is supposed to

  1. read a text file
  2. puts its content into the output

Problem: Output shows up in console window while not showing in html
output.

Method itself:
def print_file_contents
file = “path/to/the/file”
infile = File.open(file, ‘r’)
while line = infile.gets
puts line
end

View template (print_file_contents.text.erb) :
<%= hp.print_file_contents %>

Note: the console output is correct. The only problem is it doesn’t
show in the browser.

Thanks in advance.
DonVito.

On Jun 23, 12:49 am, DonVito [email protected] wrote:

Hello Everyone.

There is a method withing controller which is supposed to

  1. read a text file
  2. puts its content into the output

puts does nothing useful in a view. Your method needs to return what
it wants displayed.

Fred