Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #7500: fixtures_csv_empty_cell_as_null.patch

File fixtures_csv_empty_cell_as_null.patch, 0.6 kB (added by yssk22, 2 years ago)
  • fixtures.rb

    old new  
    322322        i = 0 
    323323        reader.each do |row| 
    324324          data = {} 
    325           row.each_with_index { |cell, j| data[header[j].to_s.strip] = cell.to_s.strip } 
     325          row.each_with_index { |cell, j| data[header[j].to_s.strip] = cell.blank? ? nil : cell.to_s.strip } 
    326326          self["#{Inflector::underscore(@class_name)}_#{i+=1}"]= Fixture.new(data, @class_name) 
    327327        end 
    328328      elsif File.file?(deprecated_yaml_file_path)