Permalink
Browse files

Destroy all before import

  • Loading branch information...
1 parent c01f9c0 commit a28b1dd1c1a82d60a7128e510dd9e0d070c256a5 @mattfordham committed Oct 25, 2013
Showing with 5 additions and 0 deletions.
  1. +4 −0 README.md
  2. +1 −0 app/models/csv_db.rb
View
@@ -2,6 +2,10 @@
CSV imports for Active Admin with one line of code.
+## IMPORTANT NOTE
+
+*This fork of the gem will delete all entries in the specified model before importing. USE AT YOUR OWN RISK.*
+
## Installation
Add this line to your application's Gemfile:
@@ -3,6 +3,7 @@ class CsvDb
class << self
def convert_save(target_model, csv_data, &block)
csv_file = csv_data.read
+ target_model.destroy_all if csv_file
CSV.parse(csv_file, :headers => true, header_converters: :symbol ) do |row|
data = row.to_hash
if data.present?

0 comments on commit a28b1dd

Please sign in to comment.