0
我有这个红宝石功能,产生1095记录MusicTab::FOps.gen_list('/fun/Music')
我想用datamapper来存储它们。当我这样做ruby Datamapper没有插入所有记录
MusicTab::FOps.gen_list('/fun/Music') do |arr_f|
@files=Files.create(
:file_path => arr_f[0],
:title => arr_f[1],
:album => arr_f[2],
:artist => arr_f[3])
end
只有154条记录被插入,我不明白这些记录是如此特别。 如果我这样做,我得到零的p @ files.id所有其他记录,而不是那些存储的154条记录。
MusicTab::FOps.gen_list('/fun/Music') do |arr_f|
@files=Files.create(
:file_path => arr_f[0],
:title => arr_f[1],
:album => arr_f[2],
:artist => arr_f[3])
p @files.id
p @files.title
p @files.album
end
如果我只是打印我可以看到所有的数值的数值一样
counter=0
MusicTab::FOps.gen_list('/fun/Music') do |arr_f|
p arr_f
counter=counter+1
end
counter
请帮助.. 问候
感谢输出@ files.errors显示的错误,file_path必须是50个字符长,在大多数情况下,它大于50,所以你可以告诉我如何增加字符串大小可能高达300或500个字符? – pahnin 2012-07-11 16:56:38
我想到了,现在它的工作很好,谢谢:) – pahnin 2012-07-11 17:02:57