two-pack/redmine_xlsx_format_issue_exporter

View on GitHub
lib/redmine_xlsx_format_issue_exporter/projects_controller_patch.rb

Summary

Maintainability
A
30 mins
Test Coverage
module RedmineXlsxFormatIssueExporter
  module ProjectsControllerPatch
    include XlsxExportHelper

    def index
      begin
        return super
      rescue ActionController::UnknownFormat => e
        if params[:format] != 'xlsx'
          raise e
        end
      end

      @entries = project_scope.to_a
      send_data(query_to_xlsx(@entries, @query, params), :type => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', :filename => 'projects.xlsx')
    end

  end
end