xls_porter 1.1.1 → 1.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/xls_porter.rb +8 -8
- metadata +1 -1
data/lib/xls_porter.rb
CHANGED
@@ -59,29 +59,29 @@ module XlsPorter
|
|
59
59
|
value = row[i]
|
60
60
|
value = value.strip if value.is_a?(String)
|
61
61
|
column = columns[i]
|
62
|
-
attribute = record.read_attribute(column)
|
63
62
|
if column == "id" and update == "new"
|
64
|
-
|
63
|
+
record[column] = value
|
65
64
|
elsif ignore_columns.include?(column)
|
66
65
|
#skip if column is ignored
|
67
|
-
elsif
|
66
|
+
elsif record[column].blank? and value.blank?
|
68
67
|
#skip if both are either nil or empty
|
69
68
|
elsif [DateTime, Time, Date].include?(value.class)
|
70
|
-
|
69
|
+
record[column] = value if attribute.to_f != value.to_f
|
71
70
|
else
|
72
|
-
if
|
73
|
-
|
71
|
+
if record[column] != value
|
72
|
+
record[column] = value
|
74
73
|
update = "updated" if update == "exist"
|
75
74
|
update_notes = [] if update_notes.nil?
|
76
75
|
update_notes << column
|
77
76
|
end
|
78
77
|
end
|
79
78
|
end
|
79
|
+
puts "Record ID:#{record.id} new? #{record.new_record?} persisted? #{record.persisted?}"
|
80
80
|
#track all updates
|
81
|
-
|
81
|
+
unless record.changed.empty?
|
82
82
|
begin
|
83
83
|
if record.save
|
84
|
-
puts "Record #{record.class}:#{record.id} saved"
|
84
|
+
puts "Record #{record.class}:#{record.id} saved #{record.persisted?}"
|
85
85
|
else
|
86
86
|
puts "Record Error #{record.error_message}"
|
87
87
|
end
|