export_controller_concern.rb 619 B

123456789101112131415161718192021222324252627282930313233
  1. # frozen_string_literal: true
  2. module Settings::ExportControllerConcern
  3. extend ActiveSupport::Concern
  4. included do
  5. before_action :authenticate_user!
  6. before_action :load_export
  7. skip_before_action :check_self_destruct!
  8. skip_before_action :require_functional!
  9. end
  10. private
  11. def load_export
  12. @export = Export.new(current_account)
  13. end
  14. def send_export_file
  15. respond_to do |format|
  16. format.csv { send_data export_data, filename: export_filename }
  17. end
  18. end
  19. def export_data
  20. raise 'Override in controller'
  21. end
  22. def export_filename
  23. "#{controller_name}.csv"
  24. end
  25. end