Sha256: 8cdff033b09e9d35fbe0ca0be725d6ed80faa022b515ed3e12c5bfe6cdea3874

Contents?: true

Size: 938 Bytes

Versions: 10

Compression:

Stored size: 938 Bytes

Contents

module Workarea
  module Admin
    class DataFileImportsController < Admin::ApplicationController
      before_action :set_import

      def new
      end

      def sample
        filename = "#{@import.name.downcase.underscore}.#{@import.file_type}"
        send_data @import.sample_file_content, filename: filename, type: @import.file_type
      end

      def create
        if @import.save
          flash[:success] = t('workarea.admin.data_file_imports.flash_messages.processing')
          redirect_to return_to.presence || root_path
        else
          render :new, status: :unprocessable_entity
        end
      end

      private

      def set_import
        @import = DataFile::Import.new(import_params)
      end

      def import_params
        base = params.select { |k, v| k.in?(DataFile::Import.fields.keys) }
        base.merge(params[:import] || {}).merge(created_by_id: current_user.id)
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
workarea-admin-3.4.21 app/controllers/workarea/admin/data_file_imports_controller.rb
workarea-admin-3.4.20 app/controllers/workarea/admin/data_file_imports_controller.rb
workarea-admin-3.4.19 app/controllers/workarea/admin/data_file_imports_controller.rb
workarea-admin-3.4.18 app/controllers/workarea/admin/data_file_imports_controller.rb
workarea-admin-3.4.17 app/controllers/workarea/admin/data_file_imports_controller.rb
workarea-admin-3.4.16 app/controllers/workarea/admin/data_file_imports_controller.rb
workarea-admin-3.4.15 app/controllers/workarea/admin/data_file_imports_controller.rb
workarea-admin-3.4.14 app/controllers/workarea/admin/data_file_imports_controller.rb
workarea-admin-3.4.13 app/controllers/workarea/admin/data_file_imports_controller.rb
workarea-admin-3.4.12 app/controllers/workarea/admin/data_file_imports_controller.rb