Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
ruby将值从sql表写入tmp文件夹_Ruby - Fatal编程技术网

ruby将值从sql表写入tmp文件夹

ruby将值从sql表写入tmp文件夹,ruby,Ruby,我有这个密码 #check if haus table is not blank if !haus.blank? temp = Dir.mkdir("C:/thistemporary/") puts "tempfolder is created" haus.each do |file| dataname = file.name da

我有这个密码

    #check if haus table is not blank   
      if !haus.blank?
             temp = Dir.mkdir("C:/thistemporary/")
         puts "tempfolder is created"
                haus.each do |file|
                dataname = file.name
                datavalue = file.data
            end
       end
我需要遍历haus表,它有“data column”(longblob)和“name column”(varchar),将每个数据及其名称和值保存在temp文件夹中。我该怎么做

感谢您的建议

if!豪斯·布兰克?
if !haus.blank?
  tempdirname = "C:/thistemporary/"
  temp = Dir.mkdir( tempdirname )
  puts "tempfolder is created"
  haus.each do |file|
    dataname = File.join( tempdirname, file.name )
    datavalue = file.data
    File.open( dataname, 'w' ){ |f| f << datavalue }
    puts "#{dataname} is created"
  end
end
tempdirname=“C:/thistemporary/” temp=Dir.mkdir(tempdirname) 放置“临时文件夹已创建” haus.each do|文件| dataname=File.join(tempdirname,File.name) datavalue=file.data
File.open(dataname,'w'){| f | f感谢您的响应。但我感到困惑,为什么您要将temp文件夹的File.join与文件名一起使用。正如预期的那样,我遇到了以下错误:无法将Fixnum转换为字符串。我使用temp2=temp.to_s,并调用File.join(temp2,File.name)但是它没有显示这样的文件或目录-0/hause_with redcolor不幸的是,它仍然没有解决这个问题,因为现在它再次显示未定义的方法`misstypted.use