Skip to content

Instantly share code, notes, and snippets.

@jraczak
Created July 31, 2014 21:37
Show Gist options
  • Save jraczak/8806c781ea979297b40a to your computer and use it in GitHub Desktop.
Save jraczak/8806c781ea979297b40a to your computer and use it in GitHub Desktop.
def save
if file.present?
cleanup_before_save
#logger.debug "--> Trying to read csv file..."
content = File.read(@file.tempfile)
#logger.debug "--> Loading csv contents into db..."
@csv_content = VenueImportCsv.create(content: content)
process_files!(@csv_content.id)
else
errors.add :csv_file, "can't be blank"
end
rescue ArgumentError, CSV::MalformedCSVError => e
errors.add :csv_file, "is not valid"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment