Search code examples
ruby-on-railsrubyruby-on-rails-3

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?


Solution

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