-
-
Save janjitsu/70dcdeae830e84df1cb38e47507fc8d5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def create | |
| @archive = Archive.new(archive_params) | |
| @archive = ArchiveProcessor.new(@archive).process | |
| if @archive.save | |
| redirect_to archives_path, notice: "The resume #{@archive.name} has been uploaded." | |
| else | |
| render "new" | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class ArchiveProcessor | |
| def initialize(archive) | |
| @archive = archive | |
| end | |
| def process | |
| 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 | |
| @archive | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment