In my InvoicesController
I have this:
def index
@invoices = current_user.invoices
respond_to do |format|
format.html
format.xls
form
Try specifying the appropriate content headers and explicitly rendering your index.csv.erb
template in your format.csv
handler block.
# app/controllers/invoices_controller.rb
format.csv do
response.headers['Content-Type'] = 'text/csv'
response.headers['Content-Disposition'] = 'attachment; filename=invoice.csv'
render :template => "path/to/index.csv.erb"
end