0

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

pahnin
  • 5,367
  • 12
  • 40
  • 57

1 Answers1

0

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.

DataMapper::Logger.new($stdout, :debug)

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.

Doon
  • 19,719
  • 3
  • 40
  • 44
  • thanks outputing @files.errors showed the error that file_path must be 50 charecters long, in most cases its larger than 50, so can u tell me how to increase the `String` size to may be upto 300 or 500 charecters? – pahnin Jul 11 '12 at 16:56