我試圖讀取一個文本文件,像這樣:「沒有這樣的文件或目錄@ rb_sysopen」當文件轉換成字符串
file = File.read(record.file)
和收到的錯誤no implicit conversion of Paperclip::Attachment into String
所以我就追加to_s最終將其轉換爲字符串:
text = File.read(record.file.to_s)
和我收到的錯誤No such file or directory @ rb_sysopen
我知道這個文件和目錄存在的事實,因爲我有一個重定向到文件的錨標記,並且這不受在末尾附加to_s影響。
我嘗試手動粘貼文件路徑,但我收到了同樣的錯誤。