Sha256: 7298072e7d29584c443fa5ae25db647817b393840d6291551b3e0e19d1f92d5d

Contents?: true

Size: 308 Bytes

Versions: 5

Compression:

Stored size: 308 Bytes

Contents

class ActionController::Responder
  def to_csv
    name = "#{controller.resource.class.name.downcase}_#{Time.now.to_i}"
    
    return controller.send_data controller.send(:end_of_association_chain).pg_copy_to_string, :filename => "/tmp/#{name}.csv", :type => "text/csv", :disposition => 'inline'
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
postgres-copy-0.5.3 lib/postgres-copy/csv_responder.rb
postgres-copy-0.5.2 lib/postgres-copy/csv_responder.rb
postgres-copy-0.5.0 lib/postgres-copy/csv_responder.rb
postgres-copy-0.4.0 lib/postgres-copy/csv_responder.rb
postgres-copy-0.3.6 lib/postgres-copy/csv_responder.rb