Reputation: 650
I am reading a txt file in ruby using File.read like below.
Let's say @name = tom
Text file contains.
Hello <%= @name %>
How can i pass @name to the text file and read it like below.
file = File.read('test.txt')
I want to pass rails instance variables to some places in txt file and read it so that file will be Hello Tom How can i achieve this? Any help will be appreciated. Thanks.
Upvotes: 0
Views: 354
Reputation: 1028
send_file path_to_file
)my_original_filename.txt.erb
erb
suffix tells Rails to process the Ruby in the text file first (Via ERB).Upvotes: 1