TitleIsbnPagesPrice
Herbrand, Danner und Göbel709686466790,00 €
Kaczmarek-Schuldt949845962810,00 €
Karus, Otto und Lammert331876948180,00 €
Polizzi-Krull592500084330,00 €
Storp, Neubert und Kurnicki223116426310,00 €
Schlitzer AG908094317560,00 €
Dittmann OHG821839751550,00 €
Leipold, Newton und Stöppler438066408250,00 €
Sewald-Spitzmüller221744357530,00 €
Koenig Gruppe927517482120,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