Ran into this issue today where basically Rails was trying to push an empty string in for a foreign key field with no value rather than a null while using CSV fixtures. Luckily, this patch did the trick:
- row.each_with_index { |cell, j| data[header[j].to_s.strip] = cell.to_s.strip }
+ row.each_with_index { |cell, j| data[header[j].to_s.strip] = cell.blank? ? nil : cell.to_s.strip }