Sha256: 7abf31ed7529b8cd993a35fa6d57c8b62f87213589e407a848461252df8e472b
Contents?: true
Size: 322 Bytes
Versions: 1
Compression:
Stored size: 322 Bytes
Contents
require 'csv' class CsvDb class << self def convert_save(model_name, csv_data) csv_file = csv_data.read CSV.parse(csv_file, :headers => true, header_converters: :symbol ) do |row| target_model = model_name.classify.constantize target_model.create!(row.to_hash) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
active_admin_importable-1.0.0 | app/models/csv_db.rb |