You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

34 lines
634 B

  1. # frozen_string_literal: true
  2. class Settings::ImportsController < ApplicationController
  3. layout 'admin'
  4. before_action :authenticate_user!
  5. before_action :set_account
  6. def show
  7. @import = Import.new
  8. end
  9. def create
  10. @import = Import.new(import_params)
  11. @import.account = @account
  12. if @import.save
  13. ImportWorker.perform_async(@import.id)
  14. redirect_to settings_import_path, notice: I18n.t('imports.success')
  15. else
  16. render :show
  17. end
  18. end
  19. private
  20. def set_account
  21. @account = current_user.account
  22. end
  23. def import_params
  24. params.require(:import).permit(:data, :type)
  25. end
  26. end