Rails:文件路径 [英] Rails: path of file
本文介绍了Rails:文件路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在 app
中有一个名为 csv
的目录,在这个目录中有一个名为 names.csv
的文件我想使用 File.read(path:string)
函数来读取文件.
文件的相对路径是什么?
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?
推荐答案
file = File.join(Rails.root, 'app', 'csv', 'names.csv')
File.read(file)
这篇关于Rails:文件路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文