logo

mastofe

My custom branche(s) on git.pleroma.social/pleroma/mastofe git clone https://hacktivis.me/git/mastofe.git

export_controller_concern.rb (519B)


  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