TitleIsbnPagesPrice
Mulrain GmbH & Co. KG789685463160,00 €
Hartmann-Forkel923770568790,00 €
Moguenara GmbH109639772920,00 €
Hache AG368533805940,00 €
Dauer GmbH & Co. KG914920192810,00 €
Grothkopp, Steffen und Hingsen193243920520,00 €
Uhlemann-Hujo873665264390,00 €
Seiler AG185186738640,00 €
Horn GmbH & Co. KG909759619350,00 €
Derr-Schmuhl579156272760,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