Sha256: aa06f8f2a446a71dfe2be5a97cebff696379cfc182bf5b2363d4b585ad550ebe

Contents?: true

Size: 1.02 KB

Versions: 1

Compression:

Stored size: 1.02 KB

Contents

#---
# Excerpted from "Crafting Rails Applications",
# published by The Pragmatic Bookshelf.
# Copyrights apply to this code. It may not be used to create training material, 
# courses, books, articles, and the like. Contact us if you are in doubt.
# We make no guarantees that this code is fit for any purpose. 
# Visit http://www.pragmaticprogrammer.com/titles/jvrails for more book information.
#---
class HomeController < ApplicationController
  def index
    respond_to do |format|
      format.html
      format.xlsx
    end
  end

  def another
    render :xlsx => "index", :filename => "filename_test.xlsx"
  end

  def render_elsewhere
    render :xlsx => "/users/index"
  end

  def withpartial
  end

  def useheader
    respond_to do |format|
      format.xlsx {
        if params[:set_direct]
          response.headers['Content-Disposition'] = "attachment; filename=\"filename_test.xlsx\""
        else
          render xlsx: "useheader", disposition: "attachment", filename: "filename_test.xlsx"
        end
      }
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
axlsx_rails-0.1.5 spec/dummy/app/controllers/home_controller.rb