TitleIsbnPagesPrice
Räntsch AG968424575980,00 €
Filipowski OHG459970287730,00 €
Humbert UG962403179520,00 €
Ochs-Siebel940867523620,00 €
Felke Gruppe148446451110,00 €
Berger-Leimbach267994299870,00 €
Burghagen-Deckert461212129600,00 €
Porsche, Bauermeister und Sussmann628638531230,00 €
Manns GmbH389161442480,00 €
Umlauft GmbH & Co. KG950534884470,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