18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
# File 'app/models2/issn_record.rb', line 18
def self.new_records(issn_records_params)
return [] unless issn_records_params
issn_records = []
IssnRecord.transaction do
issn_records_params.each do |k, v|
next if v['_destroy'] == '1'
if v['body'].present?
issn_record = IssnRecord.where(body: v['body'].gsub(/[^0-9x]/i, '')).first_or_create!
elsif v['id'].present?
issn_record = IssnRecord.find(v['id'])
else
v.delete('_destroy')
issn_record = IssnRecord.create(v)
end
issn_records << issn_record
end
end
issn_records
end
|