TitleIsbnPagesPrice
Grotke GmbH158451992570,00 €
Neupert-Balkow837693282300,00 €
Katzinski-Schwarzer272833435520,00 €
Wichmann-Wiechmann926509620880,00 €
Frenzel OHG508058389920,00 €
Bussmann, Winkelmann und Hache697589800460,00 €
Vieweg GmbH & Co. KG926075634690,00 €
Zeuch-Hehl184657144400,00 €
Flore-Knorscheidt770887877730,00 €
Kahlmeyer, Blassneck und Brettschneider344321859640,00 €

Download as CSV

HAML:
= table_go_for @books, Book, :table_html => {:class => 'table table-striped table-hover table-bordered'} do |t|
  - t.column :title
  - t.column :isbn
  - t.column :pages
  - t.column :price, :as => :currency
= link_to('Download as CSV', books_path(format: :csv), class: 'btn btn-primary')
Controller:
# frozen_string_literal: true

class BooksController < ApplicationController
  def index
    @books = Book.paginate(pagination_defaults)

    respond_to do |format|
      format.html
      format.csv do
        send_data(render_to_string(template: 'books/index', format: :csv),
                  type: 'text/csv; charset=utf-8; header=present',
                  filename: 'books.csv',
                  disposition: 'attachment')
      end
    end
  end
end