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.

30 lines
519 B

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