Class: C80Estate::AjaxAreasController

Inherits:
ActionController::Base
  • Object
show all
Defined in:
app/controllers/c80_estate/ajax_areas_controller.rb

Instance Method Summary collapse

Instance Method Details

#exel_importObject



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'app/controllers/c80_estate/ajax_areas_controller.rb', line 4

def exel_import

  is_ok = true
  errs = {
      "areas_exel" => [

      ]
  }

  begin
    @import_result = Area.import_excel(params[:file])
  rescue => e
    Rails.logger.debug "ERROR: #{e}"
    errs["areas_exel"].push(e.to_s)
    is_ok = false
  end

  # TODO:: Excel: реализовать вывод тех ошибок, которые возникли при импорте: например: таблица была импортирована за исключением таких-то полей

  respond_to do |format|
    if is_ok
      format.js { render json: errs, status: :ok }
      format.json
      format.html
    else
      format.js { render json: errs, status: :unprocessable_entity }
      format.json
      format.html
    end
  end

end