rubyforgood/casa

View on GitHub
app/controllers/mileage_reports_controller.rb

Summary

Maintainability
A
20 mins
Test Coverage
A
100%
require "csv"

class MileageReportsController < ApplicationController
  after_action :verify_authorized

  def index
    authorize :application, :see_reports_page?
    mileage_report = MileageReport.new(current_organization.id)

    respond_to do |format|
      format.csv do
        send_data mileage_report.to_csv,
          filename: "mileage-report-#{Time.current.strftime("%Y-%m-%d")}.csv"
      end
    end
  end
end