app/controllers/import_controller.rb
# include ActionController::Live # for sse (progress bar updatess)
include ActionController::Live # for sse (progress bar updatess)
include ActionController :: Live # for sse ( progress bar updatess )
def create
    file = params[:file]
    begin
      if file.blank?
        flash[:error] = 'Ningún file selecionado.'
        redirect_to action: 'new', status: 303
      elsif file.headers['Content-Type: text/csv'] ||
            file.headers['Content-Type: application/vnd.ms-excel']
        ImportLogic2.import_csv(file)
        flash[:notice] = " Records Importados en:  segundos"
        redirect_to debts_path
      else
        flash[:error] = 'No es un CSV'
        flash[:notice] = file.headers
        redirect_to action: 'new', status: 303
      end
    end
  end
def create file = params [ :file ] begin if file . blank? flash [ :error ] = 'Ningún file selecionado.' redirect_to action : 'new' , status : 303 elsif file . headers [ 'Content-Type: text/csv' ] || file . headers [ 'Content-Type: application/vnd.ms-excel' ] ImportLogic2 . import_csv ( file ) flash [ :notice ] = " Records Importados en:  segundos" redirect_to debts_path else flash [ :error ] = 'No es un CSV' flash [ :notice ] = file . headers redirect_to action : 'new' , status : 303 end end end
include ActionController::Live # for sse (progress bar updatess)
include ActionController :: Live # for sse ( progress bar updatess )
# flash[:notice] = "#{result[:total_lines]} Records Importados en: #{result[:time]} segundos"