app/models/esr_file.rb in vesr-1.0.0 vs app/models/esr_file.rb in vesr-1.0.1
- old
+ new
@@ -29,10 +29,21 @@
after_save :create_records
private
def create_records
- File.new(file.current_path).each {|line|
- self.esr_records << EsrRecord.new.parse(line) unless line[0..2] == '999'
- }
+ File.new(file.current_path).each do |line|
+ if EsrRecord.supported_line?(line)
+ esr_records << create_esr_record(line)
+ else
+ Rails.logger.info "VESR: Ignoring line #{line}"
+ end
+ end
+ end
+
+ def create_esr_record(line)
+ record = EsrRecord.new.parse(line)
+ record.save
+ Rails.logger.error "VESR: Record #{record.inspect} is invalid: #{record.errors.inspect}" unless record.valid?
+ record
end
end