Skip to content

Instantly share code, notes, and snippets.

@toniesteves
Created August 28, 2016 00:42
Show Gist options
  • Save toniesteves/353dc799c7a53b477496232e61eb4996 to your computer and use it in GitHub Desktop.
Save toniesteves/353dc799c7a53b477496232e61eb4996 to your computer and use it in GitHub Desktop.
def create
@archive = Archive.new(archive_params)
@archive.receipt = 0;
options = {:col_sep => "\t", :row_sep => "\n"}
SmarterCSV.process(archive_params[:attachment].path,options) do |chunk|
chunk.each do |data_hash|
@archive.receipt += data_hash[:price]
Order.create!( data_hash )
end
end
if @archive.save
redirect_to archives_path, notice: "The resume #{@archive.name} has been uploaded."
else
render "new"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment