I’m trying to open a file with variables encased inside the
interpolation operator, but when I open the file it escapes the #
character. I try and gsub it but it reinserts the escape character
anyway. Is there anyway to make ruby ignore the # character so I can
use variables in files?
I’m trying to open a file with variables encased inside the
interpolation operator, but when I open the file it escapes the #
character. I try and gsub it but it reinserts the escape character
anyway. Is there anyway to make ruby ignore the # character so I can
use variables in files?
When you read it in, it is a String, not code being interpreted.
Rather than trying to interpolate data in a file, try using ERB.
Here is the example from the docs written using a file rather than
string: