Ruby on Rails CSV upload&import - File name too long
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I want to let admins import contacts via csv files into the database. Therefore I am using the ruby csv library and the following code snippet: if request.post? && params[:file].present? inputFile = params[:file].read CSV.foreach(inputFile) do |row| #save row here end end However in CSV.foreach(inputFile) do |row| I get an "Errno::ENAMETOOLONG - File name too long"-error and the error message shows me that it uses the whole csv file as file name. Does anyone know why it does that? BTW: The csv file is using ',' and '/n' as delimiters. 回答1: