socksocket socksocket - 2 months ago 14
Ruby Question

Rails: path of file

I have inside

app
a directory called
csv
and inside this dir I have a file called
names.csv

I want to use
File.read(path:string)
function to read the file.

what is the relative path to the file?

Answer
file = File.join(Rails.root, 'app', 'csv', 'names.csv')
File.read(file)
Comments