Displaying 2 results from an estimated 2 matches for "locallink".
2006 Aug 15
0
duplicate entry mystery
...d
updates the local database accordingly. Anyway, things work great for the most
part, but there is a section of code which seems to randomly raise errors. I
have something like this:
homelinks = Syncinventorydesc.find(:all)
InventoryDescription.delete_all()
for link in homelinks
locallink = InventoryDescription.new()
locallink.inventory_id = link.inventory_id
locallink.description_id = link.description_id
locallink.save!
end
this code tears down the local table completely before going through each item
fetched on the remote db and inserting them in. Every now an...
2006 Aug 16
0
mysterious ''duplicate entry'' database error when building table
...in question:
begin #rescue block in event remote db is unreachable
homelinks = Syncinventorydesc.find(:all) #fetch all records
rescue
end
InventoryDescription.delete_all() #drop all records from local table
for link in homelinks #for each record we fetched..
locallink = InventoryDescription.new()
locallink.inventory_id = link.inventory_id
locallink.description_id = link.description_id
locallink.save! #insert into table
end
since it was just a duplicate entry (no loss of data) i just wrapped that save
in a rescue block too. the...