2015-07-28 54 views
0

我有一個紅寶石控制器文件每次

def new 
    counter = 1 
    fileW = File.new("query_output.txt", "w") 
    file = File.new("query_data.txt", "r") 
    while (line = file.gets) 
     puts "#{counter}: #{line}" 
     query = "select name,highway from planet_osm_line where name ilike '" +line+"'" 
     @output = PlanetOsmLine.connection.execute(query) 
     @output.each do |output| 
      fileW.write(output['highway'] + "\n") 
     end 
     counter = counter + 1 
    end 
    file.close 
    query = "" 
    @output = PlanetOsmLine.connection.execute(query) 
end 

所以在這我是從一個文件中像

%12th%main% 
    %100 feet% 
    %12th%main% 
    %12th%main% 
    %12th%main% 
    %100 feet% 

閱讀在Ruby控制檯我可以看到所有的查詢得到執行,但在刪除query_output.txt我只得到最後一個查詢的輸出。我在這裏做錯了什麼?

回答