Commit 580ad00f by liyijie

Add valid? for import method

parent efc2555a
...@@ -67,6 +67,8 @@ module TalltyImportExport ...@@ -67,6 +67,8 @@ module TalltyImportExport
line_info = convert_data(line_info) line_info = convert_data(line_info)
# 处理每行对于导入的动作,处理line_info # 处理每行对于导入的动作,处理line_info
return unless valid?(line_info)
import_record(line_info, associations) import_record(line_info, associations)
context.last_line_info = line_info context.last_line_info = line_info
end end
...@@ -89,6 +91,11 @@ module TalltyImportExport ...@@ -89,6 +91,11 @@ module TalltyImportExport
end.with_indifferent_access end.with_indifferent_access
end end
# 通过转换后,数据是否合法,如果不合法,则直接跳过不处理这个数据
def valid? line_info
true
end
def import_headers def import_headers
klass.try(:headers) || klass.try(:model_headers) || (raise ArgumentError.new('missing import_headers')) klass.try(:headers) || klass.try(:model_headers) || (raise ArgumentError.new('missing import_headers'))
end end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment