Class: AhoyCaptain::ExportsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/ahoy_captain/exports_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#period

Methods included from Rangeable

#period

Methods included from CompareMode

#compare_mode?, #comparison_mode, included

Instance Method Details

#showObject



5
6
7
8
9
10
11
12
# File 'app/controllers/ahoy_captain/exports_controller.rb', line 5

def show
  export = Export.new(params, self).build
  file = export.to_zip
  send_data file.read,
            type: 'application/zip',
            disposition: 'attachment',
            filename: "AhoyCaptain export #{request.host} #{range[0].to_date} to #{(range[1] || Time.current).to_date}.zip"
end