Skip to content

Commit

Permalink
Destroy all before import
Browse files Browse the repository at this point in the history
  • Loading branch information
mattfordham committed Oct 25, 2013
1 parent c01f9c0 commit a28b1dd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@


CSV imports for Active Admin with one line of code. 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 ## Installation


Add this line to your application's Gemfile: Add this line to your application's Gemfile:
Expand Down
1 change: 1 addition & 0 deletions app/models/csv_db.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ class CsvDb
class << self class << self
def convert_save(target_model, csv_data, &block) def convert_save(target_model, csv_data, &block)
csv_file = csv_data.read csv_file = csv_data.read
target_model.destroy_all if csv_file
CSV.parse(csv_file, :headers => true, header_converters: :symbol ) do |row| CSV.parse(csv_file, :headers => true, header_converters: :symbol ) do |row|
data = row.to_hash data = row.to_hash
if data.present? if data.present?
Expand Down

0 comments on commit a28b1dd

Please sign in to comment.