大家好我正在从数据库中取回数据并将其存储在File.i中,我正在以yaml格式存储数据。红宝石 - 无法读取yaml文件
require 'mysql2'
require 'yaml'
client = Mysql2::Client.new(:host => "localhost",:username => 'root' , :password => 'root' , :database => 'jgroup')
results = client.query("SELECT * FROM jivegroup")
File.open("D:/j.yml","w") do |file|
results.each do |index|
file.write(index.to_yaml);
end
end
below is my file "j.yml"
---
groupID: 1000
name: T1
description: ""
creationDate: 1209446456903
modificationDate: 1378128624533
---
groupID: 1001
name: T2
description:
creationDate: 1209446473683
modificationDate: 1378181717000
---
但whenver我试图加载具有YAML上述文件加载::这是给我的只有第一个记录。我想加载所有记录,请帮助。下面 是我读YML文件
YAML::load(File.read('D:/jivegroup.yml'))
{"groupID"=>1000, "name"=>"T1", "description"=>"", "creationDate"=>1209446456903, "modificationDate"=>1378128624533}
嘿,谢谢你好建议 – user2588480