I have this ruby function which yields 1095 records MusicTab::FOps.gen_list('/fun/Music')
and I want to store them using datamapper. When I do this
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
only 154 records are inserted, I don’t understand what is so special about these records.
If I do this I get nil for p @files.id all the other records other than those 154 records which gets stored.
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
If I just print the values I can see all the values like
counter=0
MusicTab::FOps.gen_list('/fun/Music') do |arr_f|
p arr_f
counter=counter+1
end
counter
please help..
Regards
try looking at @files.errors. My guess is that you are failing a validation and it isn’t getting saved.
You can try enabling some Debug logging and see if that helps to isolate the problem.
It would be helpful to see your Model Definition for the Files object, and a sample of the data that doesn’t get saved, and one that does. The last time I ran into this issue was when I needed to set the size on my text fields as I was overflowing the default.