Class: CloudXLSRails::XLSXResponder

Inherits:
Object
  • Object
show all
Defined in:
lib/cloudxls-rails/handlers/xlsx.rb

Class Method Summary collapse

Class Method Details

.redirect!(controller, scope, options) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/cloudxls-rails/handlers/xlsx.rb', line 8

def self.redirect!(controller, scope, options)
  xdata = options[:data] || {}
  unless (xdata.has_key?(:text) ||
          xdata.has_key?(:url ) ||
          xdata.has_key?(:file)  )

    xdata[:text] = CloudXLS::CSVWriter.text(scope, options)
  end

  xopts = {:data => xdata}
  xopts[:sheet] = options[:sheet] if options[:sheet]
  xopts[:doc]   = options[:doc] || {}
  xopts[:doc][:format] = 'xlsx'

  response = CloudXLS.xpipe(xopts)
  controller.redirect_to response.url
end